# kaneo-app/app architecture

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

- Interactive diagram: https://gitdiagram.com/kaneo-app/app
- Repository: https://github.com/kaneo-app/app

## Overview

##### Main Components
- Backend API: Represented by the apps/api folder. This “API” service contains controllers for activities, projects, tasks, users, workspaces, and workspace-users. It uses configuration files such as Dockerfile and database schema files (like those under apps/api/src/database) and relies on a toolset that includes Drizzle ORM (drizzle.config.ts) for data handling and migrations.
- Frontend Web: Represented by the apps/web folder. This service is built with a modern frontend stack (with routes, components, hooks, and state management for projects, tasks, teams, and authentication). It is set up to connect to the API, and there’s a dedicated Dockerfile, Vite configuration, and environmental configuration files.
- Database: The README and Docker compose file indicate the use of a database file (e.g., SQLite via DB_PATH) supporting the backend.
- Shared Modules/Libraries: Note the “packages” directory which includes shared libraries (packages/libs) and typescript configurations (packages/typescript-config). This indicates some code reuse and common config standards across the whole stack.
- Docker and CI/CD Infrastructure: The project includes multiple GitHub workflows and Docker configurations (apps/api/Dockerfile, apps/web/Dockerfile) that serve for automated builds and deployments.

##### Relationships and Interactions
- Backend-to-Database Interaction: The API interacts with the database (transactions, schema changes, migrations via drizzle, etc). Illustrate data flow between the API and the database.
- Shared Libraries Usage: Indicate that both frontend and backend may leverage shared utilities or configurations from the “packages” folder.

##### Architectural Patterns and Design Principles
- MVC/Microservice Patterns in the Backend: The API structure is modular, with defined “controllers”, “events”, “utils”, and “schema”. Emphasize separation of concerns by labeling these areas.
- Full-Stack Separation: Clearly delineate the frontend client (responsible for the user interface and client-side routing using React/Vite) and the backend services that handle business logic and data management.
- Containerization: Show that both frontend and backend are containerized via Docker. This supports portability and scalability.

##### Technologies and Frameworks
- Backend: Node.js/TypeScript, Express-like routing (implied by controllers and API endpoints), Drizzle ORM.
- Frontend: React (or a similar library – identifiable through components/hooks, .tsx files) with Vite for bundling, using a router and state management.
- Database: Likely SQLite (given the DB_PATH variable), though it might be abstracted further.
- CI/CD & DevOps: GitHub Actions workflows, Docker Compose for local orchestration.
- Utilities: Shared libraries for common functionalities (e.g., eden.ts in packages/libs) and common code styling/type configurations (via packages/typescript-config).

##### Final Touches
– Ensure every component is labeled clearly.
– Consider adding annotations for key environment variables used (KANEO_API_URL, JWT_ACCESS, DB_PATH) which indicate connection points and security settings.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Top-Level Components
    UB("User Browser"):::frontend
    FW("Frontend Web Client"):::frontend
    BA("Backend API"):::backend
    DB("Database (SQLite)"):::database
    SM("Shared Modules & TS Config"):::shared
    INF("Docker & CI/CD"):::infrastructure

    %% Subgraph: Backend API Modules
    subgraph "Backend API Modules"
        AC("Activity Controller"):::backend
        PC("Project Controller"):::backend
        TC("Task Controller"):::backend
        UC("User Controller"):::backend
        WC("Workspace Controller"):::backend
        WUC("Workspace-User Controller"):::backend
        subgraph "Drizzle ORM & Migrations"
            DOC("Drizzle ORM Config"):::backend
            DOM("Drizzle ORM Migrations"):::backend
            DS("Database Schema"):::backend
        end
    end

    %% Subgraph: Shared Libraries
    subgraph "Shared Libraries"
        SL("Shared Libraries"):::shared
        TS("TypeScript Config"):::shared
    end

    %% Subgraph: CI/CD & Containerization
    subgraph "CI/CD & Containerization"
        DBK("Dockerfile (Backend)"):::infrastructure
        DFK("Dockerfile (Frontend)"):::infrastructure
        GH("GitHub Workflows"):::infrastructure
        DC("Docker Compose File"):::infrastructure
    end

    %% Connections between Top-Level Components
    UB -->|"HTTP_Request"| FW
    FW -->|"API_Call"| BA
    BA -->|"DB_Query"| DB
    FW -->|"Uses"| SM
    BA -->|"Uses"| SM

    %% Internal Backend API Structure
    BA -->|"Contains"| AC
    BA -->|"Contains"| PC
    BA -->|"Contains"| TC
    BA -->|"Contains"| UC
    BA -->|"Contains"| WC
    BA -->|"Contains"| WUC
    UC -->|"Utilizes"| DOC
    DOC -->|"Initiates"| DOM
    DOM -->|"Structures"| DS
    DS --> DB

    %% Infrastructure connections (Containerization & CI/CD)
    BA --- DBK
    FW --- DFK
    DBK --- GH
    DFK --- GH
    GH --- DC

    %% Click Events
    click BA "https://github.com/kaneo-app/app/tree/main/apps/api"
    click AC "https://github.com/kaneo-app/app/tree/main/apps/api/src/activity"
    click PC "https://github.com/kaneo-app/app/tree/main/apps/api/src/project"
    click TC "https://github.com/kaneo-app/app/tree/main/apps/api/src/task"
    click UC "https://github.com/kaneo-app/app/tree/main/apps/api/src/user"
    click WC "https://github.com/kaneo-app/app/tree/main/apps/api/src/workspace"
    click WUC "https://github.com/kaneo-app/app/tree/main/apps/api/src/workspace-user"
    click DOC "https://github.com/kaneo-app/app/blob/main/apps/api/drizzle.config.ts"
    click DOM "https://github.com/kaneo-app/app/tree/main/apps/api/drizzle"
    click DS "https://github.com/kaneo-app/app/tree/main/apps/api/src/database"
    click FW "https://github.com/kaneo-app/app/tree/main/apps/web"
    click SL "https://github.com/kaneo-app/app/tree/main/packages/libs"
    click TS "https://github.com/kaneo-app/app/tree/main/packages/typescript-config"
    click DBK "https://github.com/kaneo-app/app/tree/main/apps/api/Dockerfile"
    click DFK "https://github.com/kaneo-app/app/tree/main/apps/web/Dockerfile"
    click GH "https://github.com/kaneo-app/app/tree/main/.github/workflows"
    click DC "https://github.com/kaneo-app/app/blob/main/compose.demo.yml"

    %% Styles
    classDef frontend fill:#AEDFF7,stroke:#333,stroke-width:2px;
    classDef backend fill:#F7D6AE,stroke:#333,stroke-width:2px;
    classDef database fill:#C2F7AE,stroke:#333,stroke-width:2px;
    classDef shared fill:#E2AEF7,stroke:#333,stroke-width:2px;
    classDef infrastructure fill:#F7AEAE,stroke:#333,stroke-width:2px;
```
