How adrianhajdin/uber works
Project’s Main Layers and Components
• Frontend Mobile Client:
• Built with React Native (Expo framework) with screens under directories such as app/(auth) and app/(root)/(tabs).
• Contains UI components (e.g., CustomButton, DriverCard, InputField) and layout components for ride booking, profiles, chat, etc.
• Integrates mapping features (Google Maps) for location and navigation display.
• Backend API Layer:
• Serverless API endpoints are found under app/(api) with several endpoints such as:
▪ Stripe endpoints (app/(api)/(stripe)) for payment processing
▪ Driver, ride creation, ride details, and user management endpoints
• These endpoints use Neon (Serverless PostgreSQL) to interact with the database.
• Database:
• PostgreSQL database (managed via NeonDB) stores data for rides, drivers, and users.
• The SQL queries and table creation scripts (e.g., CREATE TABLE drivers, CREATE TABLE rides, CREATE TABLE users) in the repository illustrate the data model.
• External Services & Integrations:
• Authentication using Clerk (with OAuth and email/password support).
• Payment processing via Stripe.
• Location and directions using Google Maps and Geoapify.
• State Management Layer:
• Client-side state management with Zustand (see store/index.ts) used to manage user location, destination, driver selection, etc.
Organizing and Diagramming the Architecture
A. Frontend:
• Inside that, include sub-components for:
• Authentication Screens (sign-in, sign-up, welcome; under app/(auth))
• Main Application Screens (book ride, confirm ride, chat, home, profile, rides tab; found under app/(root)/(tabs) and other root-level files like book-ride.tsx)
• UI Components (group or annotate “Reusable UI Components” such as CustomButton, InputField, Map, DriverCard).
• State Management (Zustand store) that coordinates user location, selected driver, etc.
B. Backend API:
• Ride Endpoints (e.g., app/(api)/ride/create+api.ts, [id]+api.ts) for ride booking and fetching ride details.
• Payment Endpoints within the Stripe folder (app/(api)/(stripe)) for creating and processing payments.
• Additional endpoints for user data and driver information.
C. Database:
• With tables such as:
▪ Drivers (with fields like id, first_name, car_image_url, etc.)
▪ Rides (with fields such as ride_id, origin/destination addresses, payment_status, etc.)
▪ Users (registration details, Clerk id, email, etc.)
D. External Services:
• Separate external service components:
• Clerk for Authentication (show connection from mobile client to external auth service)
• Stripe for payments (from mobile client and/or through API endpoints)
• Google Maps/Geoapify for location data and directions (used in both frontend for mapping and backend calculations).
Relationships and Data Flow
• The Mobile Client calls API endpoints (GET, POST) to create rides or fetch driver details.
• The API layer interacts with the PostgreSQL database (data insertion, queries, joins).
• Payment processing flows from the mobile app through the Stripe endpoints.
• External services such as Clerk and Google Maps are integrated both at the UI (for login and map rendering) and backend (for computing travel times).
Architectural Patterns and Principles
• The project uses a clear separation of concerns (presentation layer, API layer, and data persistence).
• It adopts a serverless approach for API endpoints facilitating easy scalability.
• The state management using Zustand is a key design principle for decoupled client-side logic.