# pabloc2a/cajalink architecture

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

- Interactive diagram: https://gitdiagram.com/pabloc2a/cajalink
- Repository: https://github.com/pabloc2a/cajalink

## Overview

##### Project type and purpose
- This is a Django‐based, full-stack web application (monolithic MVT pattern).
- It provides credit simulation features for end users, plus separate staff and user panels.

##### File structure
- Top-level “config” directory holds project settings, URL routing (ASGI/WSGI), and environment configs.
- Several Django apps each encapsulate a domain:
– core: shared functionality (middleware, context processors, common models/views)
– users: authentication, user services, email notifications
– credit_simulator: credit-simulation forms, services, views, templates
– staffpanel: staff-only CRUD and reporting interfaces
– userpanel: authenticated user dashboards and history pages
– legacy_models: wrappers over existing database tables/migrations
- Templates directory organizes HTML by app, plus global layouts and email templates.
- Manage.py and requirements.txt signal standard Django project management.

##### README (assumed typical Django setup)
- Likely describes Django version, Python requirements, database settings, and app overviews.
- Would reference external services (SMTP for emails) or caching if used.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    Browser["Client Browser"]:::frontend
    CDN["CDN / Static Files"]:::external
    Browser -->|"Fetch Static Assets"| CDN
    Browser -->|HTTPS Request| Nginx

    %% Infrastructure Layer
    Nginx["Nginx Reverse Proxy"]:::external
    Gunicorn["Gunicorn WSGI Server"]:::external
    Nginx -->|Proxy to WSGI| Gunicorn

    %% Application Entry
    config["config (ASGI/WSGI, URL router)"]:::backend
    Gunicorn -->|Invoke Django| config

    %% Middleware & Routing
    config -->|Apply Middleware & Context Processors| core
    config -->|Route to View| users
    config -->|Route to View| credit_simulator
    config -->|Route to View| staffpanel
    config -->|Route to View| userpanel
    config -->|Route to View| legacy_models

    %% Application Layer: Apps
    subgraph "Django Apps" 
        direction TB
        core["core (middleware, context processors)"]:::service
        users["users (auth, email, signals)"]:::service
        credit_simulator["credit_simulator (forms, services)"]:::service
        staffpanel["staffpanel (CRUD, selectors)"]:::service
        userpanel["userpanel (dashboards, history)"]:::service
        legacy_models["legacy_models (DB wrappers)"]:::service
    end

    %% Data Layer
    DB["Relational Database"]:::db
    core -->|Models Access| DB
    users -->|Models Access| DB
    credit_simulator -->|Models Access| DB
    staffpanel -->|Models Access| DB
    userpanel -->|Models Access| DB
    legacy_models -->|Legacy Schema| DB

    %% External Services
    SMTP["SMTP / Email Provider"]:::external
    users -->|Send Email| SMTP

    %% Response Flow
    credit_simulator -->|Render Template| config
    staffpanel -->|Render Template| config
    userpanel -->|Render Template| config
    core -->|Render Template| config
    users -->|Render Template| config
    legacy_models -->|Render Template| config
    config -->|HTTP Response| Browser

    %% Click Events
    click config "https://github.com/pabloc2a/cajalink/blob/main/config/urls.py"
    click core "https://github.com/pabloc2a/cajalink/blob/main/core/__init__.py"
    click users "https://github.com/pabloc2a/cajalink/blob/main/users/__init__.py"
    click credit_simulator "https://github.com/pabloc2a/cajalink/blob/main/credit_simulator/__init__.py"
    click staffpanel "https://github.com/pabloc2a/cajalink/blob/main/staffpanel/__init__.py"
    click userpanel "https://github.com/pabloc2a/cajalink/blob/main/userpanel/__init__.py"
    click legacy_models "https://github.com/pabloc2a/cajalink/blob/main/legacy_models/__init__.py"
    click CDN "https://github.com/pabloc2a/cajalink/tree/main/templates/"
    click Browser "https://github.com/pabloc2a/cajalink/blob/main/manage.py"

    %% Styles
    classDef frontend fill:#f9f,stroke:#333,stroke-width:2px
    classDef backend fill:#bbf,stroke:#333,stroke-width:2px
    classDef service fill:#bfb,stroke:#333,stroke-width:2px
    classDef db fill:#fbf,stroke:#333,stroke-width:2px
    classDef external fill:#ffe,stroke:#333,stroke-width:2px
```
