# level09/enferno architecture

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

- Interactive diagram: https://gitdiagram.com/level09/enferno
- Repository: https://github.com/level09/enferno

## Overview

##### Main Components
- Backend Web Framework: The core is the Python/Flask application found in the “enferno” directory – including key files like app.py, settings.py, and extensions modules. This represents the application server responsible for routing, authentication, API endpoints, and server-side logic.
- Database: The application uses SQLAlchemy with configurations in the .env and README. It supports both SQLite (development) and PostgreSQL (production) as defined by the SQLALCHEMY_DATABASE_URI.
- Task Queue/Background Worker: The presence of “enferno/tasks” and the README integrations for Celery (with Redis as both broker and result backend) indicate an asynchronous task processing component.
- Authentication & Security Modules: The project integrates Flask-Security, Flask-Dance for OAuth (supporting Google and GitHub) with comprehensive security templates (under “enferno/templates/security”), and many security features (such as 2FA and CSRF protection).
- Developer Tools/IDE Integration: The “.cursor” directory (with rules for Python, UI, Vue-Jinja, etc.) shows additional tooling for enforcing code style and assisting in development.

##### Out Relationships and Interactions
- How the Frontend communicates with the Backend via API calls (using Axios on the client).
- How the backend interacts with both the Database (using SQLAlchemy) and the Task Queue system (via Celery with Redis).
- Connections for OAuth – marking integration points with external services (Google, GitHub) for authentication.
- Nginx as an entry point that proxies requests to the Flask app and serves static content.
- Docker containers setup (as shown in docker-compose.yml): how each service (Flask app, Redis, PostgreSQL, Celery workers, and Nginx) runs in its container.

##### Architectural Patterns and Design Principles
- The project follows an MVC-like pattern with separation of concerns. Server-side logic, models, views (templates) and static files (client-side code) are separately organized.
- Use of Blueprints or modular separation can be indicated (e.g., "portal", "user", and possibly “public” modules) – each with its own views and models.
- Emphasis on security (CSRF, secure cookies, OAuth) is central to the design.
- The containerized, microservices-inspired deployment architecture enhances scalability and separation of runtime concerns.

##### Including Technologies, Frameworks, and Libraries
- Python 3.11+, Flask, SQLAlchemy, Celery, Redis, and PostgreSQL/SQLite.
- Deployment and DevOps include Docker, docker-compose, and Nginx.
- Developer tooling with “cursor rules” and MkDocs for documentation are also part of the ecosystem.

##### Final Advice
Every major architectural component is captured. Avoid oversimplification by including both internal module separation (for example, separating authentication, public, and portal functionalities) and external service integration. Make sure to document all data flows, dependencies, and how containerized deployment provides resilience and scalability. This detailed approach will give a principal software engineer a clear and comprehensive view of Enferno’s system architecture.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Interface: Frontend Client
    subgraph "Frontend Client"
        VUE["Vue.js Frontend"]:::frontend
        STATIC["Static Assets"]:::frontend
    end

    %% Routing Layer
    NGINX["Nginx Reverse Proxy"]:::nginx

    %% Backend Application
    subgraph "Backend Services"
        FLASK["Flask Application (Backend)"]:::backend
        AUTH["Auth & Security Modules"]:::security
    end

    %% Data and Task Processing
    subgraph "Data and Task Processing"
        DB["Database (PostgreSQL/SQLite)"]:::database
        CELERY["Celery Worker (Task Queue)"]:::taskworker
        REDIS["Redis (Broker/Backend)"]:::taskworker
    end

    %% Deployment and Developer Tools
    subgraph "Deployment & Developer Tools"
        DOCKER["Deployment Infrastructure"]:::deployment
        TOOLS["Developer Tools"]:::tools
    end

    %% External Authentication Providers
    OAUTH["OAuth Providers (Google,GitHub)"]:::external

    %% Connections
    VUE -->|"sends API calls"| NGINX
    STATIC -->|"provides assets"| NGINX
    NGINX -->|"proxies requests"| FLASK
    FLASK -->|"queries"| DB
    FLASK -->|"enqueues tasks"| CELERY
    CELERY -->|"executes via"| REDIS
    FLASK -->|"handles auth"| AUTH
    AUTH -->|"communicates with"| OAUTH
    FLASK ---|"runs in"| DOCKER
    NGINX ---|"runs in"| DOCKER
    CELERY ---|"runs in"| DOCKER
    DB ---|"runs in"| DOCKER
    REDIS ---|"runs in"| DOCKER
    TOOLS ---|"supports"| FLASK

    %% Click Events
    click FLASK "https://github.com/level09/enferno/blob/master/enferno/app.py"
    click VUE "https://github.com/level09/enferno/tree/master/enferno/public"
    click STATIC "https://github.com/level09/enferno/tree/master/enferno/static"
    click DB "https://github.com/level09/enferno/blob/master/.env-sample"
    click CELERY "https://github.com/level09/enferno/blob/master/enferno/tasks/__init__.py"
    click AUTH "https://github.com/level09/enferno/tree/master/enferno/templates/security"
    click NGINX "https://github.com/level09/enferno/tree/master/nginx"
    click DOCKER "https://github.com/level09/enferno/blob/master/docker-compose.yml"
    click TOOLS "https://github.com/level09/enferno/blob/master/.cursor"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef backend fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef database fill:#f8d7da,stroke:#721c24,stroke-width:2px;
    classDef taskworker fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef nginx fill:#e2e3e5,stroke:#6c757d,stroke-width:2px;
    classDef deployment fill:#d1ecf1,stroke:#0c5460,stroke-width:2px;
    classDef security fill:#f5c6cb,stroke:#721c24,stroke-width:2px;
    classDef external fill:#e2e3e5,stroke:#6c757d,stroke-width:2px;
    classDef tools fill:#fefefe,stroke:#6c757d,stroke-width:2px;
```
