|
1 | 1 | # Dynamic Pricing Engine
|
2 |
| - |
3 |
| -A full-stack, microservice-based Dynamic Pricing Engine for airline ticketing. It's designed to be highly scalable, observable, and maintainable, following modern FAANG-level engineering standards. |
4 |
| - |
5 |
| -The core unique selling point is the system's ability to balance short-term profit with long-term customer loyalty by integrating behavioural economics hooks with machine learning models. |
6 |
| - |
7 |
| ---- |
8 |
| - |
9 |
| -## Architecture |
10 |
| - |
11 |
| -The system consists of several core microservices that work together: |
12 |
| - |
13 |
| -- **Core Engine**: A Python service responsible for the central pricing logic. It ingests user data, competitor prices, and business goals to compute the optimal price using a combination of ML models and heuristics. |
14 |
| -- **Dashboard API**: A FastAPI server that provides an interface for business users to tune the pricing engine's parameters (e.g., loyalty vs. profit weighting) and view performance metrics. |
15 |
| -- **Frontend Dashboard**: A React/TypeScript single-page application for interacting with the Dashboard API. |
16 |
| -- **Data Stores**: PostgreSQL for persistent settings and Redis for caching, sessions, and real-time data. |
17 |
| -- **Adapters**: Pluggable modules that allow for applying behavioural nudges (e.g., "Only 3 seats left at this price!") on the consuming frontend. |
18 |
| - |
19 |
| -### Data Flow |
20 |
| - |
21 |
| -```mermaid |
22 |
| -sequenceDiagram |
23 |
| - participant U as User Browser |
24 |
| - participant S as Search Service |
25 |
| - participant C as Core Engine |
26 |
| - participant A as Amadeus Client |
27 |
| - participant API as Dashboard API |
28 |
| - participant D as Dashboard UI |
29 |
| -
|
30 |
| - U->>S: POST /search {user criteria} |
31 |
| - S->>A: get_token() & fetch_offers(params) |
32 |
| - A-->>S: raw offers JSON |
33 |
| - S->>C: engine.get_price(user, competitors) |
34 |
| - C-->>S: optimized price |
35 |
| - S-->>U: {ourPrice, comps} |
36 |
| -
|
37 |
| - D->>API: GET/PUT /settings |
38 |
| - API->>C: Propagate settings update |
39 |
| - C-->>API: Acknowledge |
40 |
| - API-->>D: dashboard parameters |
41 |
| -``` |
42 |
| - |
43 |
| ---- |
44 |
| - |
45 |
| -## Tech Stack |
46 |
| - |
47 |
| -- **Backend**: Python 3.11, FastAPI, Pydantic, HTTPX, ONNX Runtime |
48 |
| -- **Frontend**: React, TypeScript, TailwindCSS, shadcn/ui, Recharts |
49 |
| -- **Data Stores**: PostgreSQL, Redis |
50 |
| -- **Infrastructure**: Docker, Kubernetes (Helm), Terraform |
51 |
| -- **CI/CD**: GitHub Actions |
52 |
| -- **Monitoring**: Prometheus, Grafana |
53 |
| - |
54 |
| ---- |
55 |
| - |
56 |
| -## Local Development Setup |
57 |
| - |
58 |
| -1. **Clone the repository:** |
59 |
| - ```bash |
60 |
| - git clone <your-repo-url> |
61 |
| - cd dynamic_pricing_engine |
62 |
| - ``` |
63 |
| - |
64 |
| -2. **Set up environment variables:** |
65 |
| - - Copy the example `.env` file: |
66 |
| - ```bash |
67 |
| - cp .env.example .env |
68 |
| - ``` |
69 |
| - - Populate the `.env` file with your credentials and settings. |
70 |
| - |
71 |
| -3. **Run the services using Docker Compose:** |
72 |
| - ```bash |
73 |
| - docker-compose up --build |
74 |
| - ``` |
75 |
| - |
76 |
| -4. **Access the services:** |
77 |
| - - **Dashboard API**: `http://localhost:8000/docs` |
78 |
| - - **Frontend UI**: `http://localhost:3000` |
79 |
| - - **PostgreSQL**: `localhost:5432` |
80 |
| - - **Redis**: `localhost:6379` |
81 |
| - - **Grafana**: `http://localhost:3001` |
82 |
| - |
83 |
| ---- |
0 commit comments