{"id":29343830,"url":"https://github.com/prrathnayake/uber_backend","last_synced_at":"2026-05-19T04:37:36.797Z","repository":{"id":300743098,"uuid":"1006413816","full_name":"prrathnayake/uber_backend","owner":"prrathnayake","description":"A modular backend system built in modern C++, inspired by Uber's architecture. This clone demonstrates core backend features such as database integration, multithreaded task execution, and centralized loggin designed for educational, portfolio, or experimental use.","archived":false,"fork":false,"pushed_at":"2025-09-26T06:52:09.000Z","size":319,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-26T07:23:16.846Z","etag":null,"topics":["conan","conan-recipe","cpp","database-management","datapattern","kafka","uber-clone"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/prrathnayake.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-06-22T08:00:22.000Z","updated_at":"2025-09-26T06:25:05.000Z","dependencies_parsed_at":"2025-06-23T11:39:52.650Z","dependency_job_id":"50d58dab-f97f-4dfc-a390-ed6d6ddaed73","html_url":"https://github.com/prrathnayake/uber_backend","commit_stats":null,"previous_names":["prrathnayake/uber_backend"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/prrathnayake/uber_backend","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prrathnayake%2Fuber_backend","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prrathnayake%2Fuber_backend/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prrathnayake%2Fuber_backend/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prrathnayake%2Fuber_backend/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/prrathnayake","download_url":"https://codeload.github.com/prrathnayake/uber_backend/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prrathnayake%2Fuber_backend/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33201986,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-18T09:27:30.708Z","status":"online","status_checked_at":"2026-05-19T02:00:06.763Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["conan","conan-recipe","cpp","database-management","datapattern","kafka","uber-clone"],"created_at":"2025-07-08T13:00:37.683Z","updated_at":"2026-05-19T04:37:36.790Z","avatar_url":"https://github.com/prrathnayake.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🚗 Uber Backend Clone (C++ Microservices) – Under Development\n\nA **modular C++ backend system** inspired by Uber’s architecture. This project simulates a microservices environment to manage users, rides, and locations, using secure, scalable, and modern design patterns.\n\n---\n\n![Untitled Diagram(10)](https://github.com/user-attachments/assets/02bb3d93-590f-4973-9c9c-e2b3b13d0ac0)\n\n---\n\n## 📦 Features\n\n- 🧩 **Microservice Architecture**\n  - Independent services: `UserManager`, `RideManager`, and `LocationManager`\n- 💾 **Multi-DB Support**: MySQL, PostgreSQL, SQLite (per service)\n- 🧵 **Thread Pool**: Asynchronous background task execution\n- 🪵 **Color-Coded Logger**: Singleton-based centralized logging\n- 🔐 **JWT Authentication**: Secure login/session using JSON Web Tokens\n- 📬 **Message Brokers**:\n  - Kafka: For inter-service events (`user_created`, etc.)\n  - RabbitMQ: For async job/event delegation with an in-memory fallback to simplify local testing\n- 📦 **Shared Libraries** via [`cpp_base`](https://github.com/prrathnayake/cpp-base)\n- ⚙️ **Secure Configuration**: Via `.env` file + environment variables\n- 🐳 **Dockerized**: Each microservice has its own Dockerfile \u0026 entrypoint\n- 🔁 **CI/CD Ready**: GitHub Actions build and push Docker images\n- 🌐 **gRPC Services**: LocationManager boots its own gRPC endpoint alongside HTTP handlers\n- 📄 **Ride Settlement Runbook**: End-to-end booking → wallet flow captured in [`docs/ride_lifecycle_settlement.md`](docs/ride_lifecycle_settlement.md)\n\n---\n\n## 🏗️ Tech Stack\n\n- **Language**: C++17 / C++20\n- **Databases**: MySQL, PostgreSQL, SQLite\n- **Message Brokers**: Apache Kafka, RabbitMQ\n- **Networking**: gRPC + Protobuf\n- **Build**: CMake + Conan\n- **Containerization**: Docker + docker-compose\n- **CI/CD**: GitHub Actions\n\n---\n\n## 📂 Project Structure\n\n```plaintext\nuber-backend/\n├── UserManager/                     # Handles users + JWT auth\n│   ├── include/                     # Headers\n│   ├── src/                         # Source\n│   └── sql_scripts/                # SQL init files\n│\n├── RideManager/                     # Handles ride matching and booking\n├── LocationManager/                 # Geolocation services (H3-based)\n│\n├── sharedUtils/                     # Logger, thread pool, config loader\n├── sharedResources/                 # Shared gRPC, Kafka, RabbitMQ, DB\n├── proto/                           # gRPC proto definitions\n├── docker/                          # Dockerfiles per service\n│\n├── entrypointUserManager.sh         # Entrypoint: UserManager\n├── entrypointRideManager.sh         # Entrypoint: RideManager\n├── entrypointLocationManager.sh     # Entrypoint: LocationManager\n│\n├── .env                             # Environment variables\n├── docker-compose.yml               # Multi-service orchestration\n├── CMakeLists.txt\n├── conanfile.py\n└── README.md\n```\n\n# 🧠 Microservice Architecture – Uber Backend Clone (C++)\n\n---\n\n## 🖥️ Server Lifecycle\n\nEach microservice follows this initialization flow:\n\n1. **Database Initialization**  \n   Initializes a dedicated SQL database for the service. This stores all persistent data relevant to the service domain.\n\n2. **HTTP Handler Launch**  \n   Sets up HTTP servers and clients, routes incoming requests to proper controllers, and manages outgoing requests.\n\n3. **Kafka Handler Activation**  \n   Initializes Kafka producers and consumers for event-driven communication between microservices.\n\n---\n\n## 🔍 Component Descriptions\n\n- **🗄️ Database**  \n  Dedicated storage per service using MySQL, PostgreSQL, or SQLite.\n\n- **🌐 HTTP Handler**  \n  Manages HTTP servers and clients. Routes requests to appropriate handlers.\n\n- **📥 HTTP Server**  \n  Listens for external or internal HTTP requests and serves responses based on API logic.\n\n- **📤 HTTP Client**  \n  Sends HTTP requests to other microservices to fetch or send data.\n\n- **🧭 Kafka Handler**  \n  Coordinates Kafka producer and consumer setup within the service.\n\n- **📩 Kafka Consumer**  \n  Subscribes to topics and listens for inter-service messages. Integrates incoming data into the service's workflow.\n\n- **📨 Kafka Producer**  \n  Publishes events/messages to Kafka topics for other microservices to consume.\n\n---\n\n## 🚗 Microservices Breakdown\n\n---\n\n### 1. UserManager Server\n**Purpose:** Manage all user-related operations\n\n**Responsibilities:**\n- Handle user registration and login\n- Manage user profiles (name, email, phone)\n- Generate JWT tokens and hash passwords (bcrypt/Argon2)\n- Publish events to Kafka/RabbitMQ (e.g., user signup)\n- Expose HTTP endpoints:\n  - `/register`\n  - `/login`\n  - `/profile`\n\n---\n\n### 2. RideManager Server\n**Purpose:** Handle ride requests, assignments, and tracking\n\n**Responsibilities:**\n- Accept and manage ride requests\n- Assign drivers based on proximity and availability\n- Track ride status (`requested → accepted → in-progress → completed`)\n- Publish/consume Kafka events (e.g., ride started, completed)\n- Expose HTTP APIs:\n  - `/requestRide`\n  - `/rideStatus`\n  - `/cancelRide`\n\n---\n\n### 3. LocationManager Server\n**Purpose:** Handle real-time geolocation tracking\n\n**Responsibilities:**\n- Track and update driver/rider locations\n- Use Uber H3 for geospatial indexing\n- Find nearby drivers or riders\n- Publish/consume location updates via Kafka/RabbitMQ\n- Provide real-time location services\n\n---\n\n## 🧪 UserManager workflow smoke test\n\nBefore committing, run the automated UserManager workflow script to ensure the\ncore CRUD paths behave as expected and that transient files are handled safely:\n\n```bash\nscripts/test_usermanager_workflow.sh\n```\n\nThe helper waits for the service to accept TCP connections on\n`USER_SERVICE_HOST:USER_SERVICE_PORT` (defaults to `localhost:8081`), then\nexecutes a signup → login → profile update → password change → delete flow. It\nfails fast when HTTP responses deviate from the expected contracts or when the\nresponse body is missing, preventing `cat: response.txt: No such file or\ndirectory` style errors.\n\nSet `USER_SERVICE_HOST`/`USER_SERVICE_PORT` to target a remote deployment if\nneeded.\n\n---\n\n## 🔧 Common Subsystems Used in All Servers\n\n- 🗃️ **Dedicated SQL Database** (MySQL/PostgreSQL/SQLite)\n- 🌐 **HTTP Server** for exposing REST APIs\n- 📡 **Kafka Handler** for event messaging (Producer + Consumer)\n- 📬 **RabbitMQ Handler** (optional command queue with thread-safe in-memory fallback)\n- 🌐 **gRPC Bootstrap Helpers** (background server lifecycle management)\n- 🔁 **gRPC Client/Server** (optional internal communication)\n- 🧵 **Thread Pool** for async task execution\n- 📋 **Singleton Logger** with colored output\n- 🔐 **.env / Env Variable Config Loader**\n\n---\n\n### 🚀 Getting Started\n\n## 🛠️ Build \u0026 Run (Manual)\n\n\u003e 🛑 **Important:** Kafka and RabbitMQ must be running before you start the service binaries.\n\nYou can start Kafka and RabbitMQ using Docker (recommended) or your local installation.\n\n### ✅ Local build\n\n```bash\nconan build . --output-folder=build --build=missing\n```\n\nThen run the binaries from `./build/Release/bin/` as needed.\n\n### 🧪 Test deployment with Docker Compose\n\n```bash\ndocker build -f docker/Dockerfile.base -t uber_base:latest .\ndocker compose -f docker/docker-compose.test-deploy.yml --env-file .env build\ndocker compose -f docker/docker-compose.test-deploy.yml --env-file .env up -d\n```\n\nBring the stack down when finished:\n\n```bash\ndocker compose -f docker/docker-compose.test-deploy.yml down\n```\n\n## 🐳 Docker Compose Setup\n\nThis project supports a fully containerized microservices environment using **Docker Compose**.\n\n---\n\n### 📦 Services\n\n| Service            | Description                                    | Port                              |\n|--------------------|------------------------------------------------|-----------------------------------|\n| `mysql_user`       | MySQL for UserManager                          | `${USERMANAGER_PORT}`             |\n| `mysql_ride`       | MySQL for RideManager                          | `${RIDEMANAGER_PORT}`             |\n| `mysql_location`   | MySQL for LocationManager                      | `${LOCATIONMANAGER_PORT}`         |\n| `kafka`            | Kafka broker (KRaft mode)                      | `${KAFKA_EXTERNAL_PORT:-9092}`    |\n| `rabbitmq`         | RabbitMQ broker + management UI                | `${RABBITMQ_AMQP_PORT:-5672}`/`${RABBITMQ_HTTP_PORT:-15672}` |\n| `redis`            | Redis cache                                    | `${REDIS_PORT:-6379}`             |\n| `usermanager`      | UserManager C++ microservice                   | `${USERMANAGER_APP_PORT}`         |\n| `ridemanager`      | RideManager C++ microservice                   | `${RIDEMANAGER_APP_PORT}`         |\n| `locationmanager`  | LocationManager C++ microservice               | `${LOCATIONMANAGER_APP_PORT}`     |\n\n---\n\n### 🔧 Environment Configuration\n\nSet your values in a `.env` file at the project root:\n\n```env\n# MySQL shared config\nMYSQL_ROOT_PASSWORD=yourRootPassword\nMYSQL_USER=uber\nMYSQL_PASSWORD=securepass\n\n# Databases\nUSERMANAGER_DB=userdb\nRIDEMANAGER_DB=ridedb\nLOCATIONMANAGER_DB=locationdb\n\n# DB Ports\nUSERMANAGER_PORT=3307\nRIDEMANAGER_PORT=3308\nLOCATIONMANAGER_PORT=3309\n\n# Application Ports\nUSERMANAGER_APP_PORT=8081\nRIDEMANAGER_APP_PORT=8082\nLOCATIONMANAGER_APP_PORT=8083\n\n# gRPC Ports\nLOCATION_MANAGER_GRPC_PORT=50051\n\n# RabbitMQ\nRABBITMQ_HOST=localhost\nRABBITMQ_PORT=5672\nRABBITMQ_USERNAME=guest\nRABBITMQ_PASSWORD=guest\nRABBITMQ_VHOST=/\n```\n\n\u003e 💡 **Tip:** When running inside the provided Docker Compose stack, set service hosts (e.g., `USER_MANAGER_HOST`, `RIDE_MANAGER_HOST`, `LOCATION_MANAGER_HOST`, `KAFKA_HOST`, `RABBITMQ_HOST`, `REDIS_HOST`) to the matching container names (`usermanager`, `ridemanager`, `locationmanager`, `kafka-bus`, `rabbitmq-bus`, `redis-cache`).\n\n### 🔧 Run Docker Compose\n\n```bash\ndocker compose -f docker/docker-compose.test-deploy.yml --env-file .env up -d\n```\n\n\n---\n\n## 🤝 Community \u0026 Project Standards\n\n- Review the [Code of Conduct](CODE_OF_CONDUCT.md) to understand the expectations for participating in this community.\n- See the [Contributing Guide](CONTRIBUTING.md) for instructions on setting up your environment, coding standards, and submitting pull requests.\n- Consult the [Security Policy](SECURITY.md) for guidance on how to responsibly disclose vulnerabilities.\n- This project is distributed under the terms of the [MIT License](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprrathnayake%2Fuber_backend","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprrathnayake%2Fuber_backend","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprrathnayake%2Fuber_backend/lists"}