# jet-labs/jet-admin architecture

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

- Interactive diagram: https://gitdiagram.com/jet-labs/jet-admin
- Repository: https://github.com/jet-labs/jet-admin

## Overview

##### Main Components
- Frontend Application: A React-based application that handles the user interface for editing data, creating queries, forming dashboards, and displaying multiple chart types.
- Backend Application: A Node.js/Express server that exposes REST APIs for database operations (full DML and DDL support), authentication, and query management.
- Database: PostgreSQL is central to the project. Note that Prisma is used as the ORM.
- External Services: Firebase (for authentication) and possibly Supabase (as the frontend configuration shows its use as a secondary data source).
- Containerization & Deployment: Dockerfiles in both the frontend and backend imply containerized deployment processes.
- Documentation: Although not part of runtime architecture, the docs directory provides additional architectural and usage insights.

##### Component Relationships and Interactions
- The Frontend communicates with the Backend via REST API endpoints. This includes API calls for authentication, API key management, executing queries, and managing dashboards and visualizations.
- The Backend interacts with PostgreSQL to perform CRUD operations and execute complex database queries. It also uses Prisma for data modeling and migrations.
- The Backend integrates with Firebase for user authentication and implements role-based, multi-tenant access control.
- External libraries such as Winston, Morgan, and other utilities help with logging, error handling, and request processing in the backend.
- Docker configurations facilitate development, deployment, and consistent runtime environments.

##### Architectural Patterns and Design Principles
- Layered Architecture: Clear separation between API routing, business logic (services), controllers, and middleware (as seen in the folder structure under modules).
- Modular Organization: Each feature (like auth, database, apiKey, tenant management, etc.) is organized as a module with its own controller, service, middleware, and routes.
- Separation of Concerns: Frontend UI logic is kept distinct from backend service logic, and further divided into contexts/hooks for state management.
- Containerization: Use Docker for both backend and frontend services, ensuring environments remain consistent in development and production.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Container
    subgraph "Frontend Container"
        F1["Frontend Application (React)"]:::frontend
        FD["Docker: Frontend Deployment"]:::docker
    end

    %% Backend Container
    subgraph "Backend Container"
        B1["Backend Application (Express)"]:::backend
        BD["Docker: Backend Deployment"]:::docker
        subgraph "Backend Modules"
            BA1["Auth Module"]:::module
            BA2["Database Module"]:::module
            BA3["Dashboard Module"]:::module
            BA4["Logging & Monitoring"]:::module
        end
        B1 -->|"RoutesTo"| BA1
        B1 -->|"Uses"| BA2
        B1 -->|"Serves"| BA3
        B1 -->|"Handles"| BA4
    end

    %% External Components
    P["PostgreSQL Database (Prisma ORM)"]:::database
    FAuth["Firebase Authentication"]:::external
    Supa["Supabase Service"]:::external
    Docs["Documentation"]:::doc

    %% Interactions
    F1 -->|"APIRequest"| B1
    B1 -->|"DBQuery"| P
    B1 -->|"AuthCall"| FAuth
    F1 -->|"Config"| Supa
    Docs -.->|"Guidelines"| F1
    Docs -.->|"Guidelines"| B1

    %% Click Events
    click F1 "https://github.com/jet-labs/jet-admin/tree/master/apps/frontend"
    click FD "https://github.com/jet-labs/jet-admin/tree/master/apps/frontend/DockerFile"
    click B1 "https://github.com/jet-labs/jet-admin/tree/master/apps/backend"
    click BD "https://github.com/jet-labs/jet-admin/tree/master/apps/backend/Dockerfile"
    click P "https://github.com/jet-labs/jet-admin/blob/master/apps/backend/prisma/schema.prisma"
    click FAuth "https://github.com/jet-labs/jet-admin/blob/master/apps/backend/config/firebase.config.js"
    click Supa "https://github.com/jet-labs/jet-admin/blob/master/apps/frontend/src/config/supabase.js"
    click Docs "https://github.com/jet-labs/jet-admin/tree/master/docs"

    %% Styles
    classDef frontend fill:#AED6F1,stroke:#1F618D,color:#1F618D;
    classDef backend fill:#F9E79F,stroke:#B7950B,color:#7D6608;
    classDef docker fill:#E6B0AA,stroke:#922B21;
    classDef module fill:#F5CBA7,stroke:#D35400;
    classDef database fill:#D4E157,stroke:#827717,color:#424242;
    classDef external fill:#A3E4D7,stroke:#2874A6,color:#1B4F72;
    classDef doc fill:#D7BDE2,stroke:#6C3483,color:#512E5F;
```
