# watizat/webapp architecture

> Architecture diagram of the GitHub repository watizat/webapp, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-02-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/watizat/webapp
- Repository: https://github.com/watizat/webapp

## Overview

##### Project type and purpose
- This is a full-stack web application (monorepo-style) with a React-based FrontOffice (public guide) and a BackOffice (admin interface) that consumes a headless CMS.
- The app is built in TypeScript, styled with Tailwind CSS, bundled by Vite, and uses Redux for client-side state plus Leaflet for maps.
- The backend (“server side”) is entirely provided by Directus (a headless CMS) running in a Docker container and backed by PostgreSQL. There is also an external Navitia transport API integration.

##### File-structure analysis
- Top-level config: .eslintrc.cjs, .prettierrc.cjs, tailwind.config.js, vite.config.ts, tsconfig.json.
- public/ contains static assets (img, manifest.json, robots.txt).
- src/ splits into:
- @types/ – global TS type defs
- api/ – Axios wrappers for Directus endpoints (admin, CRUD), Navitia, organisms, user
- components/ – feature-driven React components, organized by BackOffice vs. FrontOffice, and further subdivided per page/section
- context/ & hooks/ – React Contexts and custom hooks for app state and BackOffice context
- utils/ – pure helper functions (axios instance, formatters, distance calculations, user roles)
- styles/ – global CSS, Tailwind reset, markdown styling
- main.tsx & router.tsx – React entrypoint and client-side router configuration

##### README insights
- Confirms the tech stack (React, Redux, TS, Vite, Tailwind, Leaflet)
- Backend: Directus + PostgreSQL in Docker
- Usage: dev server at localhost:5173, no custom server code in repo

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Frontend (Browser & Hosting)" 
        direction TB
        Browser["Browser Client"]:::frontend
        AssetLoader["Asset Loader\n(Vite Dev Server / Static Host)"]:::frontend
        ReactFrontOffice["React FrontOffice\n(public UI, search, map views)"]:::frontend
        ReactBackOffice["React BackOffice\n(admin dashboard, data edition, user management)"]:::frontend
        StateMgmt["State Management Layer\n(Redux + Context)"]:::frontend
        ContextProviders["Context Providers"]:::frontend
        CustomHooks["Custom Hooks"]:::frontend
        APIClient["API Client Layer\n(Axios wrappers)"]:::frontend
        Utils["Utility Functions"]:::frontend
        UIPrimitives["UI Primitives\n(icons)"]:::frontend
        Styles["Global & Tailwind Styles"]:::frontend
        AssetLoader --> Browser
        Browser --> ReactFrontOffice
        Browser --> ReactBackOffice
        ReactFrontOffice --> StateMgmt
        ReactBackOffice --> StateMgmt
        StateMgmt --> ContextProviders
        StateMgmt --> CustomHooks
        StateMgmt --> APIClient
        APIClient --> Utils
        ReactFrontOffice --> UIPrimitives
        ReactBackOffice --> UIPrimitives
        ReactFrontOffice --> Styles
        ReactBackOffice --> Styles
    end

    subgraph "Backend (Infrastructure)" 
        direction TB
        DockerDirectus["Directus CMS\n(Docker Container)"]:::backend
        Postgres["PostgreSQL Database"]:::db
        DockerDirectus --> Postgres
    end

    Navitia["Navitia Transport API"]:::external

    CICD["CI/CD Pipeline"]:::infra

    Browser -->|HTTPS/JSON REST| DockerDirectus
    ReactFrontOffice -->|HTTPS/JSON REST| DockerDirectus
    ReactBackOffice -->|HTTPS/JSON REST| DockerDirectus
    ReactFrontOffice -->|HTTPS/JSON| Navitia
    ReactBackOffice -->|HTTPS/JSON| Navitia
    CICD -->|Deploy Frontend Assets| AssetLoader
    CICD -->|Deploy Directus Container| DockerDirectus

    %% Click Events
    click ReactFrontOffice "https://github.com/watizat/webapp/tree/main/src/components/FrontOffice"
    click ReactBackOffice "https://github.com/watizat/webapp/tree/main/src/components/BackOffice"
    click ContextProviders "https://github.com/watizat/webapp/blob/main/src/context/AppStateContext.tsx"
    click CustomHooks "https://github.com/watizat/webapp/blob/main/src/hooks/appState.ts"
    click APIClient "https://github.com/watizat/webapp/tree/main/src/api"
    click Utils "https://github.com/watizat/webapp/blob/main/src/utils/axios.ts"
    click Utils "https://github.com/watizat/webapp/blob/main/src/utils/format.ts"
    click Utils "https://github.com/watizat/webapp/blob/main/src/utils/distance.ts"
    click Utils "https://github.com/watizat/webapp/blob/main/src/utils/user.ts"
    click Utils "https://github.com/watizat/webapp/blob/main/src/utils/userRoles.ts"
    click Utils "https://github.com/watizat/webapp/blob/main/src/utils/form/form.ts"
    click UIPrimitives "https://github.com/watizat/webapp/blob/main/src/ui/icon/icon.tsx"
    click Styles "https://github.com/watizat/webapp/blob/main/tailwind.config.js"
    click Styles "https://github.com/watizat/webapp/blob/main/src/styles/index.css"
    click Styles "https://github.com/watizat/webapp/blob/main/src/styles/reset.css"
    click Styles "https://github.com/watizat/webapp/blob/main/src/styles/elements/index.css"
    click Styles "https://github.com/watizat/webapp/blob/main/src/styles/elements/tooltips.css"
    click Styles "https://github.com/watizat/webapp/blob/main/src/styles/markdown.module.css"
    click AssetLoader "https://github.com/watizat/webapp/tree/main/public/"
    click AssetLoader "https://github.com/watizat/webapp/blob/main/index.html"
    click AssetLoader "https://github.com/watizat/webapp/blob/main/vite.config.ts"
    click TypeDefs "https://github.com/watizat/webapp/tree/main/src/@types"
    click Router "https://github.com/watizat/webapp/blob/main/src/router.tsx"
    click Entrypoint "https://github.com/watizat/webapp/blob/main/src/main.tsx"

    %% Additional nodes for mapping
    TypeDefs["TypeScript Type Definitions"]:::frontend
    Router["Client-side Routing"]:::frontend
    Entrypoint["App Entrypoint"]:::frontend

    %% Styles and Utils connection
    ReactFrontOffice --> TypeDefs
    ReactBackOffice --> TypeDefs
    ReactFrontOffice --> Router
    ReactBackOffice --> Router
    ReactFrontOffice --> Entrypoint
    ReactBackOffice --> Entrypoint

    %% Styles and Utils grouping
    classDef frontend fill:#c3ddff,stroke:#0366d6,color:#000;
    classDef backend fill:#c6f7e2,stroke:#028a0f,color:#000;
    classDef db fill:#fef3c7,stroke:#b45309,color:#000;
    classDef infra fill:#e2e8f0,stroke:#475569,color:#000;
    classDef external fill:#ffecd1,stroke:#d97706,color:#000;
```
