# satish-0001/project architecture

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

- Interactive diagram: https://gitdiagram.com/satish-0001/project
- Repository: https://github.com/satish-0001/project

## Overview

##### Project Type and Purpose
- Nextproject is a Frappe/ERPNext add-on (a full-stack plugin) that extends ERPNext’s Project module into a full PMIS.
- It lives within the Frappe framework, providing new DocTypes, server-side logic (Python), client UIs (JavaScript & Jinja templates), background schedulers, REST APIs, reports, and GitHub/ICS integrations.

##### File Structure Analysis
- Top-level: standard Frappe app files (setup.py, hooks.py, api.py, config/, patches/, fixtures/).
- nextproject/nextproject: core Python modules defining DocTypes, dashboards, reports, patches, print formats.
- public/: client-side JS assets.
- templates/ and www/: Jinja HTML templates for pages and public website (e.g., book_appointment).
- patches/: migration scripts run on bench update.
- fixtures/: JSON for initial custom fields/data.
- hooks.py: registration of document events, scheduled jobs, REST endpoints.

##### Key README Insights
- The app offers billing, resource planning, timesheets, scrum, Github integration, performance modules, risk management, reporting.
- Installable via bench; runs under Frappe’s HTTP/WSGI server, communicates with MariaDB, Redis, background worker processes.

##### Main Components
a. Frontend Layer
- Browser clients (ERPNext desk & public pages).
- Static assets (public/js/*.js, public/images, www/* HTML/CSS/JS).
- Jinja templates (/templates/pages, /templates/emails).
b. Backend Layer
- Frappe Framework Core (HTTP router, ORM, DocType engine, scheduler, job queue).
- ERPNext Core App (core Project module, base doctypes).
- Nextproject App modules:
- DocType definitions (nextproject/nextproject/doctype/*).
- Server scripts (Python controllers, hooks.py, api.py).
- Scheduled tasks (config/desktop.py, custom_scheduler.py).
- Patch scripts (patches/v13_0/*.py).
- Fixtures loader.
c. Data Layer
- MariaDB (tables auto-generated from DocTypes).
- Redis (cache, job queue).
- File store (for attachments, ICS generation).
d. External Integrations
- GitHub REST API (commit history, webhooks).
- Email/ICS API (SMTP or external calendar invites).

##### Relationships & Data Flows
- Client → HTTP(S) → Nginx/Bench → Frappe Router
- Routes to ERPNext or Nextproject REST endpoints/API (api.py) or desk views.
- Serves static JS/CSS from public/.
- Frappe → ORM → MariaDB (CRUD on DocType tables).
- Hooks → Business Logic → Reports/PDF/Print Formats.
- Scheduled Jobs (cron via bench scheduler) → run custom_scheduler.py, patches.
- Background Workers (Redis queue) → long-running tasks (email sending, billing runs).
- Nextproject → GitHub API calls (commit retrieval).
- Nextproject → ICS file creation → email dispatch.

##### Architectural Patterns & Principles
- MVC via Frappe’s DocType (Model), server scripts (Controller), JS/Jinja views (View).
- Plugin architecture: Nextproject registers via hooks, decoupled from core ERPNext.
- Event-driven: use of document event hooks (on_update, validate).
- Batch processing: scheduler + worker queue.
- Modular: each PMIS feature as its own DocType/report module.

##### Execution Steps
1. Sketch high-level layers (Client / Frappe / Data / External).
2. Within Frappe layer, show “ERPNext Core” and “Nextproject Plug-in” side by side.
3. Drill into Nextproject: sub-modules (DocTypes, Hooks, Scheduler, API, UI templates).
5. Important modules (e.g., custom_scheduler.py runs nightly billing, patches/v13_0 for migration).

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Layer
    subgraph "Client Layer"
        direction TB
        BrowserClients["Browser Clients"]:::external
        ERPNextDeskUI["ERPNext Desk UI"]:::external
        PublicPages["Public Pages"]:::external
        BrowserClients --> ERPNextDeskUI
        BrowserClients --> PublicPages
    end

    %% Static Assets & Templates
    subgraph "UI Assets & Templates"
        direction TB
        StaticJS["Static JS"]:::nextproj
        click StaticJS "https://github.com/satish-0001/project/tree/main/nextproject/public/js/"
        StaticImages["Static Images"]:::nextproj
        click StaticImages "https://github.com/satish-0001/project/tree/main/nextproject/public/images/"
        DeskTemplates["Desk Jinja Templates"]:::nextproj
        click DeskTemplates "https://github.com/satish-0001/project/tree/main/nextproject/templates/pages/"
        EmailTemplates["Email Jinja Templates"]:::nextproj
        click EmailTemplates "https://github.com/satish-0001/project/tree/main/nextproject/templates/emails/"
        PublicWebsite["Public Pages Templates"]:::nextproj
        click PublicWebsite "https://github.com/satish-0001/project/tree/main/nextproject/www/book_appointment/"
    end

    ERPNextDeskUI --> StaticJS
    ERPNextDeskUI --> StaticImages
    ERPNextDeskUI --> DeskTemplates
    PublicPages --> PublicWebsite
    PublicPages --> EmailTemplates

    %% Server Layer
    Nginx["Nginx / Bench HTTP Server"]:::frappecore

    %% Frappe Core
    subgraph "Frappe Core" 
        direction TB
        Router["HTTP Router"]:::frappecore
        ORM["ORM Engine"]:::frappecore
        SchedulerCore["Scheduler"]:::frappecore
        JobQueue["Job Queue"]:::frappecore
    end

    %% ERPNext Core
    ERPNextCore["ERPNext Core App"]:::erpnext

    %% Nextproject Plugin
    subgraph "Nextproject App Modules"
        direction TB
        ConfigHooks["Hooks & Config"]:::nextproj
        click ConfigHooks "https://github.com/satish-0001/project/blob/main/nextproject/hooks.py"
        DesktopConfig["Desktop Config"]:::nextproj
        click DesktopConfig "https://github.com/satish-0001/project/blob/main/nextproject/config/desktop.py"
        DocsConfig["Docs Config"]:::nextproj
        click DocsConfig "https://github.com/satish-0001/project/blob/main/nextproject/config/docs.py"
        DocTypes["DocType Definitions"]:::nextproj
        click DocTypes "https://github.com/satish-0001/project/tree/main/nextproject/nextproject/doctype/"
        APIEndpoints["Custom API Endpoints"]:::nextproj
        click APIEndpoints "https://github.com/satish-0001/project/blob/main/nextproject/api.py"
        SchedulerTasks["Scheduled Tasks"]:::nextproj
        click SchedulerTasks "https://github.com/satish-0001/project/blob/main/nextproject/custom_scheduler.py"
        Fixtures["Fixtures Loader"]:::nextproj
        click Fixtures "https://github.com/satish-0001/project/blob/main/nextproject/fixtures/custom_field.json"
        PatchScripts["Patch Scripts"]:::nextproj
        click PatchScripts "https://github.com/satish-0001/project/tree/main/nextproject/nextproject/patches/v13_0/"
        Dashboards["Dashboards & Charts"]:::nextproj
        click Dashboards "https://github.com/satish-0001/project/blob/main/nextproject/nextproject/workspace/pmis/pmis.json"
        click Dashboards "https://github.com/satish-0001/project/blob/main/nextproject/nextproject/nextproject_dashboard/pmis/pmis.json"
        NumberCards["Number Cards"]:::nextproj
        click NumberCards "https://github.com/satish-0001/project/tree/main/nextproject/nextproject/number_card/"
        Reports["Reports & Scripts"]:::nextproj
        click Reports "https://github.com/satish-0001/project/tree/main/nextproject/nextproject/report/"
        PrintFormats["Print Formats"]:::nextproj
        click PrintFormats "https://github.com/satish-0001/project/tree/main/nextproject/nextproject/print_format/"
        GitHubIntegration["GitHub Integration"]:::nextproj
        click GitHubIntegration "https://github.com/satish-0001/project/tree/main/nextproject/nextproject/doctype/github_repository/"
        click GitHubIntegration "https://github.com/satish-0001/project/tree/main/nextproject/nextproject/doctype/github_settings/"
        click GitHubIntegration "https://github.com/satish-0001/project/tree/main/nextproject/nextproject/doctype/pull_request_log/"
        click GitHubIntegration "https://github.com/satish-0001/project/tree/main/nextproject/nextproject/doctype/error_pull_request_log/"
        ICSExample["ICS Template"]:::nextproj
        click ICSExample "https://github.com/satish-0001/project/blob/main/nextproject/nextproject/doctype/example.ics"
        UIJinja["UI Jinja Templates"]:::nextproj
        click UIJinja "https://github.com/satish-0001/project/tree/main/nextproject/templates/pages/"
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        MariaDB["MariaDB"]:::datastore
        Redis["Redis"]:::datastore
        FileStore["File Store"]:::datastore
    end

    %% External Integrations
    subgraph "External Services"
        direction TB
        GitHubAPI["GitHub REST API"]:::external
        EmailService["Email/ICS Service"]:::external
    end

    %% Core App Module Files
    CoreInit["App Init & Packaging"]:::nextproj
    click CoreInit "https://github.com/satish-0001/project/blob/main/nextproject/__init__.py"
    click CoreInit "https://github.com/satish-0001/project/blob/main/nextproject/modules.txt"
    click CoreInit "https://github.com/satish-0001/project/blob/main/setup.py"
    click CoreInit "https://github.com/satish-0001/project/blob/main/pyproject.toml"
    click CoreInit "https://github.com/satish-0001/project/blob/main/requirements.txt"

    %% Connections
    ERPNextDeskUI -->|HTTP| Nginx
    PublicPages -->|HTTP| Nginx
    Nginx --> Router
    Router --> ERPNextCore
    Router --> APIEndpoints
    Router --> ConfigHooks
    Router --> UIJinja
    Router --> StaticJS
    Router --> StaticImages

    APIEndpoints -->|"ORM CRUD"| ORM
    ConfigHooks -->|"registers events"| Router
    ORM --> MariaDB
    SchedulerCore -->|"schedule jobs"| SchedulerTasks
    SchedulerTasks -->|"DB migrations"| MariaDB
    SchedulerTasks -.->|async| JobQueue
    JobQueue -->|runs tasks| Reports
    JobQueue -->|runs tasks| PrintFormats
    JobQueue -->|runs tasks| EmailService
    JobQueue -->|runs tasks| GitHubAPI

    Reports --> MariaDB
    PrintFormats --> MariaDB

    ConfigHooks --> Fixtures
    Fixtures --> MariaDB

    GitHubIntegration -->|calls| GitHubAPI
    ICSExample -->|generates ICS| FileStore
    EmailService -->|SMTP send| FileStore

    Router --> SchedulerCore
    SchedulerCore --> JobQueue

    %% Styles
    classDef frappecore fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef erpnext fill:#90EE90,stroke:#333,stroke-width:1px
    classDef nextproj fill:#FFA500,stroke:#333,stroke-width:1px
    classDef external fill:#D3D3D3,stroke:#333,stroke-width:1px
    classDef datastore fill:#FFFF99,stroke:#333,stroke-width:1px
```
