# oussama-filali/usine-ia architecture

> Architecture diagram of the GitHub repository oussama-filali/usine-ia, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/oussama-filali/usine-ia
- Repository: https://github.com/oussama-filali/usine-ia

## Overview

1. This repository is a small monorepo with two runtime surfaces:
   - `immersive-brain/`: the main interactive frontend
   - `api/`: a Node-based backend and data/maintenance layer
   Supporting material lives in `docs/` and the repo root.

2. The frontend is a Vite + TypeScript app (`immersive-brain/`) built around React components. Its architecture is section-driven rather than page-driven: `HeroSection`, `Intro`, `MissionSection`, `ProjectsSection`, `TeamSectionUpdated`, `NewsletterSection`, and related “Updated” variants indicate a single long-form landing experience composed of modular sections.

3. A major distinguishing feature of the frontend is its immersive/visual layer. Components like `BrainScene`, `SpaceStationScene`, `SpaceBoiSection`, `HeartMorph`, `Particles`, `SketchfabViewer`, and `AudioLayer`/`AmbientAudio` point to a presentation-heavy UI with 3D models, animated effects, and layered audio. Static assets in `public/models` and `public/images` are part of that visual subsystem.

4. The frontend entry path is standard for a Vite app: `src/main.tsx` boots `App.tsx`, which then assembles the section components. `global.css` and `tailwind.config.cjs` indicate Tailwind-based styling with global CSS for theme/layout control. `useScrollReactive.ts` suggests scroll position is used to drive interactive transitions or reveal effects across sections.

5. There is a clear error/isolation boundary in the UI through `ErrorBoundary.tsx`, which is important because the app contains heavy media/3D dependencies that can fail independently. `SpaceBoiLoader.tsx` also suggests asynchronous loading states for expensive assets.

6. The backend in `api/` is a separate Node service with `server.js` as the main runtime entry. Based on the file set, it likely exposes HTTP endpoints used by the frontend for content or newsletter interactions, while also handling data access and scheduled/batch tasks. The presence of a dedicated `package.json` and lockfile reinforces that it is deployed independently from the frontend.

7. Persistence is centered on Supabase. The `api/supabase/` folder contains SQL for `create-articles-table.sql`, `create-newsletter-table.sql`, `drop-newsletter-table.sql`, and `fix-rls-newsletter.sql`, so the backend’s data boundary is a Postgres-backed Supabase database with row-level security concerns. This means the system’s main durable state is article content and newsletter signups/digest data.

8. There are two clear backend data flows:
   - `import-articles.js` likely seeds or syncs article content into the `articles` table.
   - `newsletter-digest.js` likely assembles newsletter-related output from stored data, probably for distribution or reporting.
   `test-db.js` is a validation utility for database connectivity/schema assumptions.

9. The frontend/backend integration boundary is likely newsletter- and content-oriented. The `NewsletterSection` on the frontend corresponds to the newsletter table and digest tooling on the backend, while “projects”/content sections likely consume article data or static content surfaced through the API. The repo does not show a CMS; instead it appears to rely on Supabase tables plus import scripts.

10. Deployment/runtime hints matter here:
   - `immersive-brain/public/.htaccess` suggests the frontend may be deployed to an Apache-hosted static environment.
   - `docs/build.bat` and `docs/start.bat` plus root `commit*.bat` suggest Windows-oriented local workflow scripts.
   - `api/.env.example` and root `.env.example` show environment-based configuration for both services.

11. The `docs/` folder is operational/documentation support, not a runtime subsystem. `FRONTEND-DESIGN-README.md` and `CHANGELOG.md` likely capture design decisions and release history, which is useful for understanding why the frontend is heavily componentized and visually complex.

12. For an architecture diagram, the best high-level shape is:
   - Users interact with the React/Vite frontend.
   - The frontend renders an immersive single-page experience with 3D/audio/scroll effects.
   - It calls a separate Node API for newsletter/content-related operations.
   - The API reads/writes Supabase/Postgres tables and runs maintenance/import scripts.
   - Static media assets are served directly from the frontend’s `public/` folder.

Main entry points: [`immersive-brain/src/App.tsx`](https://github.com/oussama-filali/usine-ia/blob/main/immersive-brain/src/App.tsx) (App), [`api/server.js`](https://github.com/oussama-filali/usine-ia/blob/main/api/server.js) (Server), [`api/supabase/README.md`](https://github.com/oussama-filali/usine-ia/blob/main/api/supabase/README.md) (Supabase), [`README.md`](https://github.com/oussama-filali/usine-ia/blob/main/README.md) (README)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_repo["Repo"]
  node_root_readme["README<br/>repo guide<br/>[README.md]"]
  node_root_env["Env example<br/>config<br/>[.env.example]"]
end

subgraph group_frontend["Frontend"]
  node_frontend_entry["Main<br/>vite entry<br/>[main.tsx]"]
  node_frontend_app["App<br/>react shell<br/>[App.tsx]"]
  node_frontend_error{{"Boundary<br/>error isolation<br/>[ErrorBoundary.tsx]"}}
  node_frontend_scroll["Scroll hook<br/>interaction hook"]
  node_frontend_hero["Hero<br/>section<br/>[HeroSection.tsx]"]
  node_frontend_intro["Intro<br/>section<br/>[IntroUpdated.tsx]"]
  node_frontend_mission["Mission<br/>section<br/>[MissionSection.tsx]"]
  node_frontend_projects["Projects<br/>section"]
  node_frontend_team["Team<br/>section"]
  node_frontend_newsletter["Newsletter<br/>section"]
  node_frontend_brain(("Brain scene<br/>3d scene<br/>[BrainScene.tsx]"))
  node_frontend_station(("Station scene<br/>3d scene"))
  node_frontend_spaceboi["SpaceBoi<br/>visual section"]
  node_frontend_audio["Audio layer<br/>audio ui"]
  node_frontend_effects(("Effects<br/>motion fx<br/>[Particles.tsx]"))
  node_frontend_loader["Loader<br/>[SpaceBoiLoader.tsx]"]
end

subgraph group_backend["Backend"]
  node_backend_server["Server<br/>node api<br/>[server.js]"]
  node_backend_import["Import articles<br/>sync script<br/>[import-articles.js]"]
  node_backend_digest["Digest<br/>batch script"]
  node_backend_test["DB test<br/>validation script<br/>[test-db.js]"]
end

subgraph group_data["Data"]
  node_data_supabase[("Supabase<br/>postgres data<br/>[README.md]")]
  node_data_articles["Articles SQL<br/>schema script"]
  node_data_newsletter["Newsletter SQL<br/>schema script"]
end

subgraph group_docs["Docs"]
  node_docs_design["Design notes<br/>doc"]
  node_docs_changelog["Changelog<br/>doc<br/>[CHANGELOG.md]"]
end

node_root_readme -->|"describes"| node_frontend_app
node_root_readme -->|"describes"| node_backend_server
node_frontend_entry -->|"boots"| node_frontend_app
node_frontend_app -->|"wraps"| node_frontend_error
node_frontend_app -->|"drives"| node_frontend_scroll
node_frontend_app -->|"assembles"| node_frontend_hero
node_frontend_app -->|"assembles"| node_frontend_intro
node_frontend_app -->|"assembles"| node_frontend_mission
node_frontend_app -->|"assembles"| node_frontend_projects
node_frontend_app -->|"assembles"| node_frontend_team
node_frontend_app -->|"assembles"| node_frontend_newsletter
node_frontend_app -->|"renders"| node_frontend_brain
node_frontend_app -->|"renders"| node_frontend_station
node_frontend_app -->|"renders"| node_frontend_spaceboi
node_frontend_app -->|"layers"| node_frontend_audio
node_frontend_app -->|"layers"| node_frontend_effects
node_frontend_app -->|"guards"| node_frontend_loader
node_backend_server -->|"runs"| node_backend_import
node_backend_server -->|"runs"| node_backend_digest
node_backend_server -->|"validates"| node_backend_test
node_backend_server -->|"reads/writes"| node_data_supabase
node_backend_import -->|"loads"| node_data_articles
node_backend_digest -->|"uses"| node_data_newsletter
node_backend_test -->|"checks"| node_data_supabase
node_data_articles -->|"defines"| node_data_supabase
node_data_newsletter -->|"defines"| node_data_supabase
node_frontend_newsletter -->|"submits to"| node_backend_server
node_docs_design -->|"documents"| node_frontend_app
node_docs_changelog -->|"tracks"| node_root_readme

click node_root_readme "https://github.com/oussama-filali/usine-ia/blob/main/README.md"
click node_root_env "https://github.com/oussama-filali/usine-ia/blob/main/.env.example"
click node_frontend_entry "https://github.com/oussama-filali/usine-ia/blob/main/immersive-brain/src/main.tsx"
click node_frontend_app "https://github.com/oussama-filali/usine-ia/blob/main/immersive-brain/src/App.tsx"
click node_frontend_error "https://github.com/oussama-filali/usine-ia/blob/main/immersive-brain/src/components/ErrorBoundary.tsx"
click node_frontend_scroll "https://github.com/oussama-filali/usine-ia/blob/main/immersive-brain/src/hooks/useScrollReactive.ts"
click node_frontend_hero "https://github.com/oussama-filali/usine-ia/blob/main/immersive-brain/src/components/HeroSection.tsx"
click node_frontend_intro "https://github.com/oussama-filali/usine-ia/blob/main/immersive-brain/src/components/IntroUpdated.tsx"
click node_frontend_mission "https://github.com/oussama-filali/usine-ia/blob/main/immersive-brain/src/components/MissionSection.tsx"
click node_frontend_projects "https://github.com/oussama-filali/usine-ia/blob/main/immersive-brain/src/components/ProjectsSection.tsx"
click node_frontend_team "https://github.com/oussama-filali/usine-ia/blob/main/immersive-brain/src/components/TeamSectionUpdated.tsx"
click node_frontend_newsletter "https://github.com/oussama-filali/usine-ia/blob/main/immersive-brain/src/components/NewsletterSectionUpdated.tsx"
click node_frontend_brain "https://github.com/oussama-filali/usine-ia/blob/main/immersive-brain/src/components/BrainScene.tsx"
click node_frontend_station "https://github.com/oussama-filali/usine-ia/blob/main/immersive-brain/src/components/SpaceStationScene.tsx"
click node_frontend_spaceboi "https://github.com/oussama-filali/usine-ia/blob/main/immersive-brain/src/components/SpaceBoiSection.tsx"
click node_frontend_audio "https://github.com/oussama-filali/usine-ia/blob/main/immersive-brain/src/components/AudioLayerUpdated.tsx"
click node_frontend_effects "https://github.com/oussama-filali/usine-ia/blob/main/immersive-brain/src/components/Particles.tsx"
click node_frontend_loader "https://github.com/oussama-filali/usine-ia/blob/main/immersive-brain/src/components/SpaceBoiLoader.tsx"
click node_backend_server "https://github.com/oussama-filali/usine-ia/blob/main/api/server.js"
click node_backend_import "https://github.com/oussama-filali/usine-ia/blob/main/api/import-articles.js"
click node_backend_digest "https://github.com/oussama-filali/usine-ia/blob/main/api/newsletter-digest.js"
click node_backend_test "https://github.com/oussama-filali/usine-ia/blob/main/api/test-db.js"
click node_data_supabase "https://github.com/oussama-filali/usine-ia/blob/main/api/supabase/README.md"
click node_data_articles "https://github.com/oussama-filali/usine-ia/blob/main/api/supabase/create-articles-table.sql"
click node_data_newsletter "https://github.com/oussama-filali/usine-ia/blob/main/api/supabase/create-newsletter-table.sql"
click node_docs_design "https://github.com/oussama-filali/usine-ia/blob/main/docs/FRONTEND-DESIGN-README.md"
click node_docs_changelog "https://github.com/oussama-filali/usine-ia/blob/main/docs/CHANGELOG.md"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_root_readme,node_root_env toneBlue
class node_frontend_entry,node_frontend_app,node_frontend_error,node_frontend_scroll,node_frontend_hero,node_frontend_intro,node_frontend_mission,node_frontend_projects,node_frontend_team,node_frontend_newsletter,node_frontend_brain,node_frontend_station,node_frontend_spaceboi,node_frontend_audio,node_frontend_effects,node_frontend_loader toneAmber
class node_backend_server,node_backend_import,node_backend_digest,node_backend_test toneMint
class node_data_supabase,node_data_articles,node_data_newsletter toneRose
class node_docs_design,node_docs_changelog toneIndigo
```

## Components

### Repo

Workspace and top-level guidance

- [README](https://github.com/oussama-filali/usine-ia/blob/main/README.md): repo guide · Top-level repository overview · `README.md`
- [Env example](https://github.com/oussama-filali/usine-ia/blob/main/.env.example): config · Shared environment template · `.env.example`

### Frontend

Vite + React immersive landing app

- [Main](https://github.com/oussama-filali/usine-ia/blob/main/immersive-brain/src/main.tsx): vite entry · Bootstraps the frontend app · `immersive-brain/src/main.tsx`
- [App](https://github.com/oussama-filali/usine-ia/blob/main/immersive-brain/src/App.tsx): react shell · Assembles the long-form immersive experience · `immersive-brain/src/App.tsx`
- [Boundary](https://github.com/oussama-filali/usine-ia/blob/main/immersive-brain/src/components/ErrorBoundary.tsx): error isolation · Protects heavy visual components from runtime failures · `immersive-brain/src/components/ErrorBoundary.tsx`
- [Scroll hook](https://github.com/oussama-filali/usine-ia/blob/main/immersive-brain/src/hooks/useScrollReactive.ts): interaction hook · Drives scroll-reactive transitions and reveals · `immersive-brain/src/hooks/useScrollReactive.ts`
- [Hero](https://github.com/oussama-filali/usine-ia/blob/main/immersive-brain/src/components/HeroSection.tsx): section · Primary landing hero section · `immersive-brain/src/components/HeroSection.tsx`
- [Intro](https://github.com/oussama-filali/usine-ia/blob/main/immersive-brain/src/components/IntroUpdated.tsx): section · Introductory section variant · `immersive-brain/src/components/IntroUpdated.tsx`
- [Mission](https://github.com/oussama-filali/usine-ia/blob/main/immersive-brain/src/components/MissionSection.tsx): section · Mission and narrative section · `immersive-brain/src/components/MissionSection.tsx`
- [Projects](https://github.com/oussama-filali/usine-ia/blob/main/immersive-brain/src/components/ProjectsSection.tsx): section · Projects and content showcase · `immersive-brain/src/components/ProjectsSection.tsx`
- [Team](https://github.com/oussama-filali/usine-ia/blob/main/immersive-brain/src/components/TeamSectionUpdated.tsx): section · Team section variant · `immersive-brain/src/components/TeamSectionUpdated.tsx`
- [Newsletter](https://github.com/oussama-filali/usine-ia/blob/main/immersive-brain/src/components/NewsletterSectionUpdated.tsx): section · Newsletter signup and call to action · `immersive-brain/src/components/NewsletterSectionUpdated.tsx`
- [Brain scene](https://github.com/oussama-filali/usine-ia/blob/main/immersive-brain/src/components/BrainScene.tsx): 3d scene · Core immersive brain visual · `immersive-brain/src/components/BrainScene.tsx`
- [Station scene](https://github.com/oussama-filali/usine-ia/blob/main/immersive-brain/src/components/SpaceStationScene.tsx): 3d scene · Space station visual environment · `immersive-brain/src/components/SpaceStationScene.tsx`
- [SpaceBoi](https://github.com/oussama-filali/usine-ia/blob/main/immersive-brain/src/components/SpaceBoiSection.tsx): visual section · Animated character section and related loading flow · `immersive-brain/src/components/SpaceBoiSection.tsx`
- [Audio layer](https://github.com/oussama-filali/usine-ia/blob/main/immersive-brain/src/components/AudioLayerUpdated.tsx): audio ui · Ambient audio and layered sound controls · `immersive-brain/src/components/AudioLayerUpdated.tsx`
- [Effects](https://github.com/oussama-filali/usine-ia/blob/main/immersive-brain/src/components/Particles.tsx): motion fx · Particles, morphing visuals, and embedded viewer · `immersive-brain/src/components/Particles.tsx`
- [Loader](https://github.com/oussama-filali/usine-ia/blob/main/immersive-brain/src/components/SpaceBoiLoader.tsx): asset loader · Loading state for expensive 3D assets · `immersive-brain/src/components/SpaceBoiLoader.tsx`

### Backend

Node API and maintenance scripts

- [Server](https://github.com/oussama-filali/usine-ia/blob/main/api/server.js): node api · Main backend runtime entry · `api/server.js`
- [Import articles](https://github.com/oussama-filali/usine-ia/blob/main/api/import-articles.js): sync script · Seeds or syncs article content · `api/import-articles.js`
- [Digest](https://github.com/oussama-filali/usine-ia/blob/main/api/newsletter-digest.js): batch script · Builds newsletter digest output · `api/newsletter-digest.js`
- [DB test](https://github.com/oussama-filali/usine-ia/blob/main/api/test-db.js): validation script · Checks database connectivity and schema assumptions · `api/test-db.js`

### Data

Supabase/Postgres persistence and schema

- [Supabase](https://github.com/oussama-filali/usine-ia/blob/main/api/supabase/README.md): postgres data · Articles and newsletter tables with RLS-managed persistence · `api/supabase/README.md`
- [Articles SQL](https://github.com/oussama-filali/usine-ia/blob/main/api/supabase/create-articles-table.sql): schema script · Creates the articles table · `api/supabase/create-articles-table.sql`
- [Newsletter SQL](https://github.com/oussama-filali/usine-ia/blob/main/api/supabase/create-newsletter-table.sql): schema script · Creates and repairs newsletter storage and RLS · `api/supabase/create-newsletter-table.sql`

### Docs

Operational and design documentation

- [Design notes](https://github.com/oussama-filali/usine-ia/blob/main/docs/FRONTEND-DESIGN-README.md): doc · Frontend architecture and design rationale · `docs/FRONTEND-DESIGN-README.md`
- [Changelog](https://github.com/oussama-filali/usine-ia/blob/main/docs/CHANGELOG.md): doc · Release and change history · `docs/CHANGELOG.md`

## Connections

- README → App: describes · Repository overview points to the main frontend experience
- README → Server: describes · Repository overview points to the backend service
- Main → App: boots · Vite entry mounts the application shell
- App → Boundary: wraps · App uses an error boundary around fragile UI
- App → Scroll hook: drives · Scroll state feeds interactive section transitions
- App → Hero: assembles · Long-form landing experience starts with the hero
- App → Intro: assembles · App composes the narrative intro section
- App → Mission: assembles · App composes the mission section
- App → Projects: assembles · App composes the projects showcase
- App → Team: assembles · App composes the team section
- App → Newsletter: assembles · App composes the newsletter call to action
- App → Brain scene: renders · App includes immersive 3D brain visuals
- App → Station scene: renders · App includes space-station scene visuals
- App → SpaceBoi: renders · App includes character-centric visual section
- App → Audio layer: layers · App layers ambient and interactive audio
- App → Effects: layers · App uses motion effects and embedded 3D media
- App → Loader: guards · App shows loading states for heavy assets
- Server → Import articles: runs · API service has maintenance/import entry points
- Server → Digest: runs · API service has newsletter batch output
- Server → DB test: validates · API service includes database validation tooling
- Server → Supabase: reads/writes · Server communicates with Supabase-backed persistence
- Import articles → Articles SQL: loads · Article import script populates article schema
- Digest → Newsletter SQL: uses · Digest generation relies on newsletter data
- DB test → Supabase: checks · Validation script verifies database access and schema
- Articles SQL → Supabase: defines · Articles table lives in the Supabase database boundary
- Newsletter SQL → Supabase: defines · Newsletter table and RLS fixes live in Supabase
- Newsletter → Server: submits to · Newsletter UI likely integrates with the backend API
- Design notes → App: documents · Design notes explain the componentized landing experience
- Changelog → README: tracks · Change history complements the repository overview
