How nlouis56/racingsetup works
Project Type and Purpose
• This is a Node.js/TypeScript monolithic backend API service (no frontend code present here).
• Purpose: power the “Setup Wizard” web/mobile client—including user auth, teams, setup sharing, and real‐time messaging/notifications.
• Exposes a GraphQL API (via resolvers under src/*/api) plus WebSocket endpoints (websocket.ts) for real‐time channels and notifications.
File Structure
• Top-level:
• backend/: contains all server code
• docker-compose.yml: orchestrates the API container + PostgreSQL
• database.sql: initial schema
• Under backend/src:
• app.ts: entry point, wires up Express, GraphQL, WebSockets, middleware
• data-source.ts + entities: TypeORM setup & entity definitions
• Feature modules:
– auth: user registration/login (JWT, hashing)
– channel: public chat channels
– message & privateMessage: posting messages, replies
– notification: push notifications over WebSocket
– file: file‐upload & retrieval
– utils: common helpers (hash, JWT)
• Each feature has api/domain.ts, api/resolver.ts, repository, routes subfolders.
README for Additional Insights
• Mentions a machine‐learning “Setup Wizard”—that likely calls out to an external ML service to suggest vehicle settings.
• Teams & community sharing suggests user‐to‐team ACLs (likely enforced in ChannelRole/ChannelSubscription).
• Real‐time updates for message/chat and possibly for ML progress.
a. Main Components
• Client Applications (Web, Mobile)
• API Server (Express + GraphQL)
• WebSocket Server (for channels & notifications)
• PostgreSQL Database (hosted in Docker)
• External Machine‐Learning Service (for the wizard)
• (Optional) Object Storage or CDN (for file uploads)
b. Relationships & Data Flow
1. Clients ←GraphQL/HTTP→ API Server
2. API Server ←→ PostgreSQL via TypeORM/Data-Source
3. Clients ←WebSocket→ API Server for real‐time channels & notifications
4. API Server ←HTTP/gRPC→ ML Service (wizard suggestions)
5. API Server ←→ Object Storage for file uploads/downloads
c. Architectural Patterns & Principles
• Modular feature-based code organization (Auth, Channel, Message, etc.)
• Repository Pattern (feature-specific PostgreSQL repo classes)
• JWT-based stateless authentication (middleware layer)
• Real-time pub/sub over WebSockets
• Containerized deployment (Docker, docker-compose)
d. Key Technologies
• Node.js, TypeScript, Express
• GraphQL (resolvers per domain)
• WebSocket (native or socket.io in websocket.ts)
• TypeORM + PostgreSQL
• Docker & docker-compose
• JWT & bcrypt (in utils)
Detailed Steps
• HTTP/GraphQL layer (app.ts, resolvers)
• Auth middleware (JWT)
• Feature modules: Auth, Channel, Message, File, Notification, PrivateMessage
• WebSocket gateway (websocket.ts)
• Data-Source/ORM layer