# zeeshan-khan-2003/acc-mgmt architecture

> Architecture diagram of the GitHub repository zeeshan-khan-2003/acc-mgmt, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-10-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/zeeshan-khan-2003/acc-mgmt
- Repository: https://github.com/zeeshan-khan-2003/acc-mgmt

## Overview

##### Project Type & Purpose
- This is a full-stack Accounting/ERP system (“Odoo – Accounting/ERP System”)
- Backend: Python + Flask + SQLAlchemy
- Frontend: Next.js 13 (app directory) + React components
- Core features: user/auth management, contacts/products, purchase & sales orders, vendor bills, customer invoices, payments, general ledger, financial reports

##### Key Architectural Components
a. Frontend (Next.js)
- UI Layer: pages in `fronted/src/app/*` (admin pages, forms, login, dashboards)
- Presentation Components: `fronted/src/components/*` and `fronted/src/components/ui/*`
- Client-side libs: `fronted/src/lib/database.js`, `health-check.js`, `utils.js`
- Build & Config: `package.json`, `next.config.mjs`, ESLint/JSConfig

b. Backend (Flask API)
- Application Entrypoint: `backend/app.py` (Flask app + route definitions)
- Data Models & ORM: `backend/schema.py` & SQLAlchemy models
- Database Connection: `backend/database.py`
- Seed & Migrations: `backend/seed.py`, `backend/insert_products.py`, `backend/dataset.sql`
- Tests: `backend/test_app.py`
- Dependencies: `backend/req.txt`

c. Database
- Core tables: Contacts_Master, Product_Master, Taxes_Master, chart_of_accounts_Master, users, purchase_orders, purchase_order_items, vendor_bills, sales_orders, sales_order_items, customer_invoices, payments, general_ledger

d. External/Supporting Services
- (Optional) File storage for static assets served by Next.js under `public/`
- CI/CD pipeline (inferred)—build & test commands for frontend and backend

##### Relationships & Data Flows
- User → Browser UI (Next.js SSR/CSR)
- User actions on forms and dashboards trigger client-side code in `src/app` and `src/components`.
- API calls via fetch/Axios to Flask REST endpoints.
- Frontend → Flask API
- Authentication endpoints (login/logout)
- CRUD endpoints for contacts, products, orders, invoices, payments, ledger entries
- Flask API → Database
- SQLAlchemy session to read/write tables per request
- Seed scripts populate master data on startup or CI runs

##### Architectural Patterns & Principles
- Separation of Concerns:
- Next.js handles presentation and routing (app folder structure).
- Flask implements business logic, validation, authentication, ORM abstraction.
- Layered Architecture:
- Presentation Layer (React)
- API Layer (Flask controllers)
- Service/Repository Layer (SQLAlchemy models)
- Persistence Layer (RDBMS)
- Modular Directory Structure:
- Frontend features co-located under `src/app/<feature>`
- Reusable UI primitives under `src/components/ui`
- Backend scripts organized by function (app, schema, seed, tests)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Tier
    subgraph "Frontend Tier"
        direction TB
        User((User))
        Pages["Pages & Routes"]:::frontend
        UIComponents["Presentation Components"]:::frontend
        UIPrimitives["UI Primitives"]:::frontend
        ClientLibs["Client-side Libraries"]:::frontend
        Config["Config & Build Files"]:::frontend
        User -->|"interacts with"| Pages
        UIComponents -->|"used by"| Pages
        UIPrimitives -->|"used by"| UIComponents
        ClientLibs -->|"utilities for"| Pages
        Config -->|"build & config for"| Pages
    end

    %% Backend Tier
    subgraph "Backend Tier"
        direction TB
        Controllers["Controllers (app.py)"]:::backend
        Services["Services & ORM (schema.py, database.py)"]:::backend
        SeedMigrations["Seed & Migrations"]:::scripts
        Tests["Test Suite"]:::scripts
        Req["Dependencies (req.txt)"]:::scripts

        Pages -->|"HTTP API calls"| Controllers
        Controllers -->|"calls ORM"| Services
        Services -->|"connects via session"| Database
        SeedMigrations -.->|"initializes data"| Database
        Tests -.->|"tests endpoints"| Controllers
        Req -->|"provides deps for"| Controllers
    end

    %% Database Tier
    subgraph "Database Tier"
        direction TB
        Database[(Relational Database)]:::database
    end

    %% Click Events
    click Pages "https://github.com/zeeshan-khan-2003/acc-mgmt/tree/main/fronted/src/app/*"
    click UIComponents "https://github.com/zeeshan-khan-2003/acc-mgmt/tree/main/fronted/src/components"
    click UIPrimitives "https://github.com/zeeshan-khan-2003/acc-mgmt/tree/main/fronted/src/components/ui"
    click ClientLibs "https://github.com/zeeshan-khan-2003/acc-mgmt/tree/main/fronted/src/lib"
    click Config "https://github.com/zeeshan-khan-2003/acc-mgmt/blob/main/fronted/package.json"
    click Controllers "https://github.com/zeeshan-khan-2003/acc-mgmt/blob/main/backend/app.py"
    click Services "https://github.com/zeeshan-khan-2003/acc-mgmt/blob/main/backend/schema.py"
    click Services "https://github.com/zeeshan-khan-2003/acc-mgmt/blob/main/backend/database.py"
    click SeedMigrations "https://github.com/zeeshan-khan-2003/acc-mgmt/blob/main/backend/seed.py"
    click Tests "https://github.com/zeeshan-khan-2003/acc-mgmt/blob/main/backend/test_app.py"
    click Req "https://github.com/zeeshan-khan-2003/acc-mgmt/blob/main/backend/req.txt"
    click Database "https://github.com/zeeshan-khan-2003/acc-mgmt/blob/main/dataset.sql"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#004085;
    classDef backend fill:#d4edda,stroke:#155724;
    classDef scripts fill:#fff3cd,stroke:#856404;
    classDef database fill:#d1ecf1,stroke:#0c5460;
```
