# rezanasirian/simple-api-generator architecture

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

- Interactive diagram: https://gitdiagram.com/rezanasirian/simple-api-generator
- Repository: https://github.com/rezanasirian/simple-api-generator

## Overview

##### Project type and purpose
- This is a full-stack web application (“Simple API Generator”) built with Flask (Python 3.8+).
- It provides a browser-based UI for non-developers to build, test, document and manage RESTful APIs without writing server code.
- The README confirms features like drag-and-drop API builder, user auth, role-based access, automatic Swagger/OpenAPI docs, database integration, logging, versioning, and multi-environment configuration.

##### File structure
- Top-level directories:
- app/            – core application package
- config/         – JSON and Python configuration files
- migrations/     – database migration scripts (Alembic style)
- instance/       – runtime SQLite database
- exports/        – generated Swagger JSON
- templates/      – Jinja2 HTML templates organized by feature
- services/, utils/, models.py, middleware/ under app/ implement business logic, helpers, and cross-cutting concerns
- app/__init__.py wires up the Flask app, loads blueprints (api, auth, dashboard, admin).
- app/api/routes holds API endpoints, including generator logic and documentation endpoints.
- app/services encapsulate database connections, query builder, user management, logging.
- app/middleware implements request-level authentication and metrics gathering.
- run.py / flask CLI is the entry point.
- config files (config.py, ApiDoc.json, db_config.json) define environment settings and default API doc structure.

##### README additional insights
- Mentions multi-environment via .env variables (SECRET_KEY, FLASK_ENV, DATABASE_URL, mail settings).
- Deployment options: Heroku, Docker.
- Testing with pytest and coverage.

## Diagram (Mermaid)

```mermaid
flowchart TB
  %% Client / UI Layer
  subgraph "Client / UI Layer"
    Browser["Web Browser"]:::external
    Static["Static Assets"]:::frontend
    Templates["HTML Templates"]:::frontend
  end

  %% API / Server Layer
  subgraph "API / Server Layer"
    AuthBP["Auth Blueprint"]:::backend
    APIBP["API Blueprint"]:::backend
    DashBP["Dashboard Blueprint"]:::backend
    AdminBP["Admin Blueprint"]:::backend
    AuthMW["Authentication Middleware"]:::backend
    MetricsMW["Metrics Middleware"]:::backend
  end

  %% Services / Business Logic
  subgraph "Services / Business Logic"
    APIQB["APIQueryBuilder Service"]:::service
    DBServ["Database Service"]:::service
    ConnServ["Connection Config Service"]:::service
    UserServ["User Manager Service"]:::service
    LogServ["Logger Service"]:::service
    Models["ORM Models"]:::service
    Utils["Utility Helpers"]:::service
  end

  %% Data / Persistence Layer
  subgraph "Data / Persistence Layer"
    Migrations["DB Migrations"]:::data
    RuntimeDB["Runtime DB\n(instance/users.db)"]:::data
    SwaggerExp["Swagger Export\n(exports/swagger.json)"]:::data
  end

  %% External Services
  subgraph "External Services"
    Email["Email Server"]:::external
    Config["Configuration Files"]:::external
  end

  %% Connections: Client to Server
  Browser -->|HTTP/AJAX| AuthBP
  Browser -->|HTTP/AJAX| APIBP
  Browser -->|HTTP/AJAX| DashBP
  Browser -->|HTTP/AJAX| AdminBP
  Browser -->|loads| Static
  Browser -->|renders| Templates

  %% Middleware usage
  AuthBP -->|uses| AuthMW
  APIBP -->|uses| AuthMW
  DashBP -->|uses| AuthMW
  AdminBP -->|uses| AuthMW

  AuthBP -->|collects| MetricsMW
  APIBP -->|collects| MetricsMW
  DashBP -->|collects| MetricsMW
  AdminBP -->|collects| MetricsMW

  %% Server to Services
  AuthBP -->|calls| UserServ
  AuthBP -->|calls| DBServ
  AuthBP -->|sends email| Email

  APIBP -->|calls| APIQB
  APIBP -->|calls| DBServ
  APIBP -->|calls| LogServ
  APIBP -->|generates spec| SwaggerExp

  DashBP -->|calls| DBServ
  AdminBP -->|calls| ConnServ
  AdminBP -->|calls| DBServ
  AdminBP -->|sends email| Email

  %% Services to Data
  DBServ -->|SQL| RuntimeDB
  ConnServ -->|config| RuntimeDB
  APIQB -->|SQL| RuntimeDB
  Migrations -->|update schema| RuntimeDB

  %% Config to components
  Config --> AuthBP
  Config --> APIBP
  Config --> DashBP
  Config --> AdminBP
  Config --> DBServ

  %% Click Events
  click AuthBP "https://github.com/rezanasirian/simple-api-generator/blob/master/app/auth.py"
  click AuthBP "https://github.com/rezanasirian/simple-api-generator/tree/master/app/templates/auth"
  click APIBP "https://github.com/rezanasirian/simple-api-generator/blob/master/app/api/routes/API_Generator.py"
  click APIBP "https://github.com/rezanasirian/simple-api-generator/blob/master/app/api/routes/apiPage.py"
  click APIBP "https://github.com/rezanasirian/simple-api-generator/blob/master/app/api/routes/api_docs.py"
  click APIBP "https://github.com/rezanasirian/simple-api-generator/tree/master/app/templates/api"
  click DashBP "https://github.com/rezanasirian/simple-api-generator/blob/master/app/dashboard.py"
  click DashBP "https://github.com/rezanasirian/simple-api-generator/blob/master/app/templates/dashboard/dashboard.html"
  click AdminBP "https://github.com/rezanasirian/simple-api-generator/blob/master/app/admin.py"
  click AdminBP "https://github.com/rezanasirian/simple-api-generator/tree/master/app/templates/admin"
  click AuthMW "https://github.com/rezanasirian/simple-api-generator/blob/master/app/middleware/auth.py"
  click MetricsMW "https://github.com/rezanasirian/simple-api-generator/blob/master/app/middleware/metrics.py"
  click APIQB "https://github.com/rezanasirian/simple-api-generator/blob/master/app/services/APIQueryBuilder.py"
  click DBServ "https://github.com/rezanasirian/simple-api-generator/blob/master/app/services/database.py"
  click ConnServ "https://github.com/rezanasirian/simple-api-generator/blob/master/app/services/connection_configs.py"
  click UserServ "https://github.com/rezanasirian/simple-api-generator/blob/master/app/services/user_manager.py"
  click LogServ "https://github.com/rezanasirian/simple-api-generator/blob/master/app/services/logger.py"
  click Models "https://github.com/rezanasirian/simple-api-generator/blob/master/app/models.py"
  click Utils "https://github.com/rezanasirian/simple-api-generator/tree/master/app/utils"
  click Static "https://github.com/rezanasirian/simple-api-generator/tree/master/app/static"
  click Templates "https://github.com/rezanasirian/simple-api-generator/tree/master/app/templates/shared"
  click Templates "https://github.com/rezanasirian/simple-api-generator/tree/master/app/templates/modals"
  click Config "https://github.com/rezanasirian/simple-api-generator/blob/master/config/config.py"
  click Config "https://github.com/rezanasirian/simple-api-generator/blob/master/config/database.py"
  click Config "https://github.com/rezanasirian/simple-api-generator/blob/master/config/ApiDoc.json"
  click Config "https://github.com/rezanasirian/simple-api-generator/blob/master/config/db_config.json"
  click Migrations "https://github.com/rezanasirian/simple-api-generator/blob/master/migrations/create_api_key_table.py"
  click Migrations "https://github.com/rezanasirian/simple-api-generator/blob/master/migrations/create_metrics_tables.py"
  click Migrations "https://github.com/rezanasirian/simple-api-generator/blob/master/migrations/metrics_tracker.py"
  click SwaggerExp "https://github.com/rezanasirian/simple-api-generator/blob/master/exports/swagger.json"
  click RuntimeDB "https://github.com/rezanasirian/simple-api-generator/blob/master/instance/users.db"
  click Browser "https://github.com/rezanasirian/simple-api-generator/blob/master/run.py"

  %% Styles
  classDef frontend fill:#D0E8F2,stroke:#333,stroke-width:1px
  classDef backend fill:#D6EFD1,stroke:#333,stroke-width:1px
  classDef service fill:#FFF2CC,stroke:#333,stroke-width:1px
  classDef data fill:#E4E4E4,stroke:#333,stroke-width:1px
  classDef external fill:#F8D7DA,stroke:#333,stroke-width:1px
```
