# naucmeit/web architecture

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

- Interactive diagram: https://gitdiagram.com/naucmeit/web
- Repository: https://github.com/naucmeit/web

## Overview

##### Project type and purpose
- This is an “Education Monorepo”: a full-stack, modular learning platform managed by Nx.
- It contains multiple deployable applications (backend API, a modern “Coursition” app, a legacy “NMIT” app) plus shared libraries (AI, API helpers, auth, DB client, UI, utilities).
- Purpose: develop, build, and deploy multiple services and UIs in a single repository with shared code, ensuring consistency and reuse.

##### File structure
- Top-level tools/config: nx.json, pnpm-workspace.yaml, .prototools, Bun/PNPM settings, husky, CI config.
- apps/
- backend – Node/Bun HTTP service (src/index.ts)
- coursition – Modern React/TSX front-end (app router under src/routes, components, theme, liveblocks)
- legacy_nmit – Next.js educational site (pages/, components/, prisma migrations, supabase config, stripe/email utils)
- libs/
- ai – document/media generation wrappers
- api – central API-v1, dev, auth, order endpoints + utilities
- auth – user types/constants
- db – Prisma client and schema
- env – runtime/env var loading via Infisical
- ui/design-system – shared UI toolkit, storybook
- utils – common helpers (date, media, subtitle, copy, random)

##### README
- Confirms monorepo managed by Nx, uses Bun as runtime, PNPM workspaces, and recommends Proto for environment consistency.
- Describes apps vs. libs separation and gives Nx commands for dev/build/test.

##### Detailed coverage
- Break “libs/api” into sub-services (auth, order, v1).
- In Coursition, annotate liveblocks real-time channel and theme/lib imports.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Core Tooling
    subgraph "Core Tooling"
        direction TB
        NX["Nx Monorepo Orchestrator"]:::core
        TOOL["Proto / Bun / PNPM Toolchain"]:::core
    end

    %% Applications
    subgraph "Applications" 
        direction TB
        BE["Backend API Service"]:::app
        CO["Coursition Front-End"]:::app
        LE["Legacy NMIT Front-End"]:::app
    end

    %% Shared Libraries
    subgraph "Shared Libraries"
        direction TB
        AI["AI Library"]:::lib
        API["API Helpers"]:::lib
        AUTH["Auth Library"]:::lib
        DBLIB["Database (Prisma) Library"]:::lib
        ENV["Environment Library"]:::lib
        UI["UI Design System"]:::lib
        UT["Utilities"]:::lib
    end

    %% Infrastructure & External
    subgraph "Infrastructure & External"
        direction TB
        DATABASE[("Database")]:::infra
        INFISICAL["Infisical (Secrets)"]:::infra
        SUPABASE["Supabase"]:::infra
        OPENAI["OpenAI / AI Endpoint"]:::infra
        STRIPE["Stripe / Email Service"]:::infra
        LIVEBLOCKS["Liveblocks (Realtime)"]:::infra
    end

    %% Dev/Build Flows
    NX -->|"orchestrates build/test"| BE
    NX -->|"orchestrates build/test"| CO
    NX -->|"orchestrates build/test"| LE
    NX -->|"manages libs"| AI
    NX -->|"manages libs"| API
    NX -->|"manages libs"| AUTH
    NX -->|"manages libs"| DBLIB
    NX -->|"manages libs"| ENV
    NX -->|"manages libs"| UI
    NX -->|"manages libs"| UT

    TOOL -.->|dev/test| NX

    %% Runtime Interactions
    CO -->|"REST/WebSocket calls"| BE
    LE -->|"REST API calls"| BE
    BE -->|"queries"| DATABASE
    BE -->|"imports"| AUTH
    BE -->|"imports"| API
    BE -->|"imports"| ENV
    BE -->|"imports"| DBLIB
    BE -->|"calls"| OPENAI
    BE -->|"uses"| AI

    CO -->|"imports UI components"| UI
    CO -->|"imports API helpers"| API
    CO -->|"imports ENV"| ENV
    CO -->|"calls"| LIVEBLOCKS
    CO -->|"uses"| AI

    LE -->|"imports UI components"| UI
    LE -->|"imports API helpers"| API
    LE -->|"imports ENV"| ENV
    LE -->|"uses Supabase"| SUPABASE
    LE -->|"uses Stripe"| STRIPE

    DATABASE -->|"managed by Prisma"| DBLIB
    INFISICAL -->|"provides secrets to"| ENV

    %% Click Events
    click NX "https://github.com/naucmeit/web/blob/master/nx.json"
    click NX "https://github.com/naucmeit/web/blob/master/tsconfig.base.json"
    click NX "https://github.com/naucmeit/web/blob/master/pnpm-workspace.yaml"
    click NX "https://github.com/naucmeit/web/blob/master/package.json"
    click TOOL "https://github.com/naucmeit/web/tree/master/.prototools/"
    click TOOL "https://github.com/naucmeit/web/blob/master/pnpm-workspace.yaml"
    click TOOL "https://github.com/naucmeit/web/blob/master/.npmrc"
    click BE "https://github.com/naucmeit/web/blob/master/apps/backend/project.json"
    click BE "https://github.com/naucmeit/web/blob/master/apps/backend/src/index.ts"
    click BE "https://github.com/naucmeit/web/blob/master/apps/backend/tsconfig.json"
    click CO "https://github.com/naucmeit/web/blob/master/apps/coursition/package.json"
    click CO "https://github.com/naucmeit/web/blob/master/apps/coursition/modern.config.ts"
    click CO "https://github.com/naucmeit/web/tree/master/apps/coursition/src/routes/"
    click CO "https://github.com/naucmeit/web/tree/master/apps/coursition/src/components/"
    click CO "https://github.com/naucmeit/web/blob/master/apps/coursition/src/lib/backend.ts"
    click CO "https://github.com/naucmeit/web/blob/master/apps/coursition/liveblocks.config.ts"
    click CO "https://github.com/naucmeit/web/blob/master/apps/coursition/modern.runtime.ts"
    click CO "https://github.com/naucmeit/web/blob/master/apps/coursition/tsconfig.json"
    click LE "https://github.com/naucmeit/web/blob/master/apps/legacy_nmit/project.json"
    click LE "https://github.com/naucmeit/web/blob/master/apps/legacy_nmit/next.config.mjs"
    click LE "https://github.com/naucmeit/web/tree/master/apps/legacy_nmit/prisma/"
    click LE "https://github.com/naucmeit/web/tree/master/apps/legacy_nmit/pages/"
    click LE "https://github.com/naucmeit/web/tree/master/apps/legacy_nmit/components/"
    click LE "https://github.com/naucmeit/web/tree/master/apps/legacy_nmit/utils/"
    click LE "https://github.com/naucmeit/web/tree/master/apps/legacy_nmit/supabase/"
    click LE "https://github.com/naucmeit/web/blob/master/apps/legacy_nmit/hooks/useTrackedUser.ts"
    click LE "https://github.com/naucmeit/web/blob/master/apps/legacy_nmit/styles/global.css"
    click LE "https://github.com/naucmeit/web/blob/master/apps/legacy_nmit/tailwind.config.js"
    click LE "https://github.com/naucmeit/web/blob/master/apps/legacy_nmit/tsconfig.json"
    click LE "https://github.com/naucmeit/web/blob/master/apps/legacy_nmit/package.json"
    click AI "https://github.com/naucmeit/web/blob/master/libs/ai/project.json"
    click AI "https://github.com/naucmeit/web/blob/master/libs/ai/src/document.ts"
    click AI "https://github.com/naucmeit/web/blob/master/libs/ai/src/generate.ts"
    click AI "https://github.com/naucmeit/web/blob/master/libs/ai/src/media.ts"
    click API "https://github.com/naucmeit/web/blob/master/libs/api/project.json"
    click API "https://github.com/naucmeit/web/blob/master/libs/api/src/api-v1.ts"
    click AUTH "https://github.com/naucmeit/web/blob/master/libs/auth/project.json"
    click AUTH "https://github.com/naucmeit/web/blob/master/libs/auth/src/constants.ts"
    click DBLIB "https://github.com/naucmeit/web/blob/master/libs/db/project.json"
    click DBLIB "https://github.com/naucmeit/web/blob/master/libs/db/src/client.ts"
    click ENV "https://github.com/naucmeit/web/blob/master/libs/env/project.json"
    click ENV "https://github.com/naucmeit/web/blob/master/libs/env/src/infisical.ts"
    click UI "https://github.com/naucmeit/web/blob/master/libs/ui/design-system/package.json"
    click UI "https://github.com/naucmeit/web/blob/master/libs/ui/design-system/.storybook/main.ts"
    click UT "https://github.com/naucmeit/web/blob/master/libs/utils/project.json"
    click UT "https://github.com/naucmeit/web/blob/master/libs/utils/src/common.ts"

    %% Styles
    classDef app fill:#D0EBFF,stroke:#1E88E5,stroke-width:2px
    classDef lib fill:#E6F4EA,stroke:#2E7D32,stroke-width:2px
    classDef core fill:#ECEFF1,stroke:#546E7A,stroke-width:2px
    classDef infra fill:#FFF3E0,stroke:#FB8C00,stroke-width:2px
```
