# masked-kunsiquat/crm architecture

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

- Interactive diagram: https://gitdiagram.com/masked-kunsiquat/crm
- Repository: https://github.com/masked-kunsiquat/crm

## Overview

##### Project Type and Purpose
- This project is a self-hosted CRM meant for personal or small business use.
- It offers a full-stack architecture where the frontend is built using React 18, TypeScript, and Vite, while the backend is powered by PocketBase (which uses SQLite for storage).
- Key features include hierarchical data management (organizations, accounts, subaccounts), audit management with a unique floor matrix visualization, and built-in authentication via PocketBase.

##### File Structure
- Notice the distinct directories:
- The “crm” folder contains the entire frontend codebase, including subdirectories for src (with API hooks, pages, components, utilities) following modern React design patterns (e.g., modular features like accounts, audits, contacts, organizations, and subaccounts).
- The “backend” folder holds PocketBase binaries and a series of migration scripts under pb_migrations which indicate schema evolution and database updates.
- The presence of a “misc_work” directory, with generator scripts and auxiliary tools, implies additional components that aid data conversion and report generation.
- Configuration, environment (e.g. .env), and build tooling files (like vite.config.ts, tailwind.config.js) are located clearly to denote separation of concerns between development environment and production.

## Diagram (Mermaid)

```mermaid
graph TD
    User["User"]:::user

    subgraph "CRM Frontend"
        FE["CRM Frontend"]:::frontend
        API["API Layer"]:::frontend
        App["App.tsx"]:::frontend
        Routes["RoutesConfig.tsx"]:::frontend
        UIShared["UI Components (Shared)"]:::frontend
        UIFeat["UI Components (Features)"]:::frontend
        Auth["Authentication"]:::frontend
    end

    subgraph "PocketBase Backend"
        PB["PocketBase Backend"]:::backend
        SQLite["Database (SQLite)"]:::backend
        Migrate["Database Migrations"]:::backend
    end

    subgraph "Miscellaneous Tools"
        Misc["Misc Work Tools"]:::misc
    end

    User -->|"interacts"| FE
    FE -->|"renders"| App
    FE -->|"handlesAuth"| Auth
    App -->|"includes"| UIShared
    App -->|"includes"| UIFeat
    Auth -->|"calls"| API
    API -->|"communicatesWith"| PB
    PB -->|"storesDataIn"| SQLite
    Migrate -->|"updates"| PB
    Misc -->|"assists"| PB

    click FE "https://github.com/masked-kunsiquat/crm/tree/main/crm/src"
    click API "https://github.com/masked-kunsiquat/crm/tree/main/crm/src/shared/api"
    click App "https://github.com/masked-kunsiquat/crm/blob/main/crm/src/App.tsx"
    click Routes "https://github.com/masked-kunsiquat/crm/blob/main/crm/src/RoutesConfig.tsx"
    click UIShared "https://github.com/masked-kunsiquat/crm/tree/main/crm/src/shared/components"
    click UIFeat "https://github.com/masked-kunsiquat/crm/tree/main/crm/src/features"
    click Auth "https://github.com/masked-kunsiquat/crm/tree/main/crm/src/features/auth"
    click Migrate "https://github.com/masked-kunsiquat/crm/tree/main/backend/pb_migrations"
    click PB "https://github.com/masked-kunsiquat/crm/tree/main/backend"
    click Misc "https://github.com/masked-kunsiquat/crm/tree/main/misc_work"

    classDef frontend fill:#E3F2FD,stroke:#1976D2,stroke-width:2px;
    classDef backend fill:#FFECB3,stroke:#F57C00,stroke-width:2px;
    classDef misc fill:#C8E6C9,stroke:#388E3C,stroke-width:2px;
    classDef user fill:#F8BBD0,stroke:#C2185B,stroke-width:2px;
```
