# lilimly/orinoco architecture

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

- Interactive diagram: https://gitdiagram.com/lilimly/orinoco
- Repository: https://github.com/lilimly/orinoco

## Overview

##### Project type and purpose
- Full-stack application: a Node.js/Express back end serving a REST API, and a static front-end (HTML/CSS/JS) hosted separately.
- Purpose: serve product data (cameras, furniture, teddy) from MongoDB to browser-based pages (index, produit, panier, confirmation).

##### File structure
- Top-level back-end files:
– server.js (boots Express, connects to MongoDB)
– app.js (sets up middleware, imports routes)
– routes/*.js (defines REST endpoints per resource: camera, furniture, teddy)
– controllers/*.js (implements business logic for each endpoint)
– models/*.js (data schema/DB-access layer for each resource)
- Static front-end (served via GitHub Pages or Express static middleware):
– HTML: index.html, produit.html, panier.html, confirmation.html
– JS: index.js, produit.js, panier.js, confirmation.js (client-side scripts using fetch to call the API)
– Styles: SCSS in scss/ → compiled into css/style.css
- Config & dependencies: package.json, node_modules, .lock file.

##### README for insights
- Confirms Node/npm setup, “npm start” → “node server”
- Server listens on localhost:3000 by default
- Front-end is accessible at a GitHub Pages URL

a. Main components:
1. Browser/Client (blue) – renders HTML, runs JS, SCSS→CSS assets
2. Front-end assets host (could be GitHub Pages or Express static)
3. API Server (green):
- Express application (server.js/app.js)
- Router layer (routes/*.js)
- Controller layer (controllers/*.js)
- Model/DB layer (models/*.js + Mongoose)
4. Database (orange): MongoDB Atlas or local MongoDB instance
5. Optional: SCSS compiler/build pipeline
- Browser → HTTP GET/POST → Express Router → Controller → Model → MongoDB
- MongoDB → Query result → Model → Controller → JSON response → Browser
- SCSS source → Build → CSS → Browser
c. Architectural patterns:
- MVC-style separation inside the API (routes → controllers → models)
- RESTful API endpoints (e.g. GET /api/cameras)
- Static asset serving for front-end
d. Key technologies:
- Node.js + Express
- Mongoose for MongoDB
- Vanilla JS fetch API on the client
- SCSS preprocessor → CSS
- GitHub Pages (or Express) for static hosting

##### Detail to capture
- Major route (camera, furniture, teddy) under the Router layer.
- Under Controllers, note business logic modules.
- Under Models, show schema definitions and DB connection.
- How SCSS files in scss/utils feed into css/style.css.
- Static-file serving (app.use(express.static(...)) or GitHub Pages).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client (Browser)" 
        direction TB
        HTMLTemplates["HTML Templates"]:::frontend
        JSFiles["Client-side JS"]:::frontend
        CSSFile["Compiled CSS"]:::frontend
    end

    %% SCSS Build Pipeline
    subgraph "SCSS Build Pipeline" 
        direction TB
        SCSSMain["scss/style.scss"]:::pipeline
        SCSSVars["scss/utils/_variables.scss"]:::pipeline
        SCSSMixins["scss/utils/_mixins.scss"]:::pipeline
        SCSSResp["scss/utils/_responsive.scss"]:::pipeline
        SCSSMain --> SCSSVars
        SCSSMain --> SCSSMixins
        SCSSMain --> SCSSResp
        SCSSMain -->|"compile"| CSSFile
    end

    %% Static Asset Relations
    HTMLTemplates -->|"serve static files"| ClientHost[Static Host]:::frontend
    JSFiles --> ClientHost
    CSSFile --> ClientHost

    ClientHost -->|"renders"| Browser[Browser]:::frontend

    %% API Server Layer
    subgraph "API Server" 
        direction TB
        ServerJS["server.js"]:::server
        AppJS["app.js"]:::server
        subgraph "Router Layer" 
            direction TB
            RouteCam["routes/camera.js"]:::router
            RouteFur["routes/furniture.js"]:::router
            RouteTed["routes/teddy.js"]:::router
        end
        subgraph "Controller Layer" 
            direction TB
            CtrlCam["controllers/camera.js"]:::controller
            CtrlFur["controllers/furniture.js"]:::controller
            CtrlTed["controllers/teddy.js"]:::controller
        end
        subgraph "Model Layer" 
            direction TB
            ModelCam["models/Camera.js"]:::model
            ModelFur["models/Furniture.js"]:::model
            ModelTed["models/Teddy.js"]:::model
        end
        ServerJS --> AppJS
        AppJS --> RouteCam
        AppJS --> RouteFur
        AppJS --> RouteTed
        RouteCam --> CtrlCam
        RouteFur --> CtrlFur
        RouteTed --> CtrlTed
        CtrlCam --> ModelCam
        CtrlFur --> ModelFur
        CtrlTed --> ModelTed
    end

    %% Database
    DB[(MongoDB)]:::db

    %% Client to API
    Browser -->|"HTTP GET/POST"| AppJS

    %% Server to DB
    ModelCam -->|-->| DB
    ModelFur -->|-->| DB
    ModelTed -->|-->| DB
    DB -->|-->| ModelCam
    DB -->|-->| ModelFur
    DB -->|-->| ModelTed

    %% Config & Dependencies
    Config["package.json\npackage-lock.json\nnode_modules/"]:::config
    AppJS --> Config

    %% Click Events
    click HTMLTemplates "https://github.com/lilimly/orinoco/blob/master/index.html"
    click HTMLTemplates "https://github.com/lilimly/orinoco/blob/master/produit.html"
    click HTMLTemplates "https://github.com/lilimly/orinoco/blob/master/panier.html"
    click HTMLTemplates "https://github.com/lilimly/orinoco/blob/master/confirmation.html"
    click JSFiles "https://github.com/lilimly/orinoco/blob/master/js/index.js"
    click JSFiles "https://github.com/lilimly/orinoco/blob/master/js/produit.js"
    click JSFiles "https://github.com/lilimly/orinoco/blob/master/js/panier.js"
    click JSFiles "https://github.com/lilimly/orinoco/blob/master/js/confirmation.js"
    click CSSFile "https://github.com/lilimly/orinoco/blob/master/css/style.css"
    click CSSFile "https://github.com/lilimly/orinoco/blob/master/css/style.css.map"
    click SCSSMain "https://github.com/lilimly/orinoco/blob/master/scss/style.scss"
    click SCSSVars "https://github.com/lilimly/orinoco/blob/master/scss/utils/_variables.scss"
    click SCSSMixins "https://github.com/lilimly/orinoco/blob/master/scss/utils/_mixins.scss"
    click SCSSResp "https://github.com/lilimly/orinoco/blob/master/scss/utils/_responsive.scss"
    click ServerJS "https://github.com/lilimly/orinoco/blob/master/server.js"
    click AppJS "https://github.com/lilimly/orinoco/blob/master/app.js"
    click RouteCam "https://github.com/lilimly/orinoco/blob/master/routes/camera.js"
    click RouteFur "https://github.com/lilimly/orinoco/blob/master/routes/furniture.js"
    click RouteTed "https://github.com/lilimly/orinoco/blob/master/routes/teddy.js"
    click CtrlCam "https://github.com/lilimly/orinoco/blob/master/controllers/camera.js"
    click CtrlFur "https://github.com/lilimly/orinoco/blob/master/controllers/furniture.js"
    click CtrlTed "https://github.com/lilimly/orinoco/blob/master/controllers/teddy.js"
    click ModelCam "https://github.com/lilimly/orinoco/blob/master/models/Camera.js"
    click ModelFur "https://github.com/lilimly/orinoco/blob/master/models/Furniture.js"
    click ModelTed "https://github.com/lilimly/orinoco/blob/master/models/Teddy.js"
    click Config "https://github.com/lilimly/orinoco/blob/master/package.json"
    click Config "https://github.com/lilimly/orinoco/blob/master/package-lock.json"
    click Config "https://github.com/lilimly/orinoco/tree/master/node_modules/"

    %% Styles
    classDef frontend fill:#bbdefb,stroke:#1e88e5,stroke-width:1px
    classDef pipeline fill:#ffecb3,stroke:#fbc02d,stroke-width:1px
    classDef server fill:#c8e6c9,stroke:#43a047,stroke-width:1px
    classDef router fill:#a5d6a7,stroke:#388e3c,stroke-width:1px
    classDef controller fill:#81c784,stroke:#2e7d32,stroke-width:1px
    classDef model fill:#66bb6a,stroke:#1b5e20,stroke-width:1px
    classDef db fill:#ffccbc,stroke:#e64a19,stroke-width:1px
    classDef config fill:#e0e0e0,stroke:#616161,stroke-width:1px
```
