# rifflere/opencourt architecture

> Architecture diagram of the GitHub repository rifflere/opencourt, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-10-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rifflere/opencourt
- Repository: https://github.com/rifflere/opencourt

## Overview

##### Project type and purpose
- This is a full-stack web application (“OpenCourt”) that helps users find, create, join, and manage open‐play sports events.
- Frontend: React app built with Vite under src/frontend/opencourt
- Backend: Node.js/Express server under src/server
- Persistence: A database layer in src/database (db.js)

##### File structure
- Top-level src folder splits into database, frontend, and server.
- src/frontend/opencourt contains standard Vite/React structure (public, src, index.html, package.json).
- src/server follows an MVC‐ish layout:
- server.js (entry point)
- routers/router.js (defines REST endpoints)
- controllers/controller.js (business logic)
- model/db.js (database connection & queries)
- src/database may hold migrations or seed scripts (verify README in that folder).

##### Extract architectural hints from README
- CRUD operations on Users, Events, Locations
- Entities and relationships:
- User ↔ Event (many‐to‐many via participation)
- Event → Location (one‐to‐one)
- Location → Event (one‐to‐many)
- Future extensions: user profiles, payment integration

##### Main components and interactions
a. Components
- Client (Browser)
– React/Vite single-page app
- API Layer
– Express Server (REST endpoints)
– Routers & Controllers
- Database
– Relational or NoSQL DB (e.g., PostgreSQL, MongoDB)
- (Optionally) Authentication Service or Payment Service (future)
b. Relationships & Data Flows
1. User loads React app → makes HTTP(S) calls to REST API
2. Router dispatches to Controller
3. Controller calls model/db to query or mutate data
4. DB returns results → Controller formats JSON → Router responds to client
c. Architectural patterns
- Three‐tier architecture (Client, Server, Data)
- MVC-style separation in the backend
- Componentized React front end
d. Key technologies
- React, Vite, JSX, CSS
- Node.js, Express.js
- Database driver (e.g., pg or mongoose)
- ESLint config for code quality

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Presentation Layer"
        React["React SPA"]:::frontend
        Vite["vite.config.js"]:::frontend
        ESLint["eslint.config.js"]:::frontend
    end

    subgraph "Application Layer"
        Server["Express Server (server.js)"]:::server
        Router["Express Router (router.js)"]:::server
        Controller["Controller (controller.js)"]:::server
        Model["Data Model (db.js)"]:::server
    end

    subgraph "Persistence Layer"
        DBcyl(("Database")):::database
        Scripts["DB Scripts / Migrations"]:::database
    end

    subgraph "External Services"
        Auth["Authentication Service"]:::external
        Payment["Payment Service"]:::external
    end

    React -->|"API calls: GET/POST/PUT/DELETE /events, /users, /locations"| Server
    Server -->|"routes requests"| Router
    Router -->|"delegates to"| Controller
    Controller -->|"queries/mutates"| Model
    Model -->|"reads/writes"| DBcyl
    DBcyl -->|"returns data"| Controller
    Controller -->|"sends JSON"| Router
    Router -->|"responds"| Server
    Server -->|"sends HTTP response"| React

    Server -.->|"auth requests"| Auth
    Server -.->|"payment integration"| Payment
    Scripts --> DBcyl

    click React "https://github.com/rifflere/opencourt/tree/main/src/frontend/opencourt"
    click Vite "https://github.com/rifflere/opencourt/blob/main/src/frontend/opencourt/vite.config.js"
    click ESLint "https://github.com/rifflere/opencourt/blob/main/src/frontend/opencourt/eslint.config.js"
    click Server "https://github.com/rifflere/opencourt/blob/main/src/server/server.js"
    click Router "https://github.com/rifflere/opencourt/blob/main/src/server/routers/router.js"
    click Controller "https://github.com/rifflere/opencourt/blob/main/src/server/controllers/controller.js"
    click Model "https://github.com/rifflere/opencourt/blob/main/src/server/model/db.js"
    click Scripts "https://github.com/rifflere/opencourt/tree/main/src/database"

    classDef frontend fill:#AEDFF7,stroke:#036,stroke-width:1px
    classDef server fill:#C6F6D5,stroke:#038,stroke-width:1px
    classDef database fill:#FFDDA0,stroke:#DC9,stroke-width:1px
    classDef external fill:#EEEEEE,stroke:#999,stroke-dasharray:5 5,stroke-width:1px
```
