# iv4n-0v/project_social_medi4 architecture

> Architecture diagram of the GitHub repository iv4n-0v/project_social_medi4, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/iv4n-0v/project_social_medi4
- Repository: https://github.com/iv4n-0v/project_social_medi4

## Overview

#### Purpose and Entry Point
Project Social MEdi4 is a Python/FastAPI application for managing users, methodologies, benefits, analyses, and reports. Its executable ASGI entry point is `main.py`, run as `uvicorn main:app`. It exposes API documentation through FastAPI and also contains Jinja2 HTML templates, so it supports server-rendered views in addition to API endpoints.
Paths: `main.py`, `templates/base.html`, `templates/index.html`

#### HTTP and Presentation Layer
`main.py` is the application composition boundary: it likely initializes FastAPI and wires domain modules into request handling. The template set indicates list, create, and edit workflows for users, methodologies, benefits, and analyses. Shared layout/navigation are separated from page-specific templates.
Paths: `main.py`, `templates/navbar.html`, `templates/user_edit.html`

#### Domain Modules
Business capabilities are partitioned into top-level modules rather than nested packages: user lifecycle, methodology management, benefit calculation/management, and analysis processing. These modules form the primary application service layer called by the HTTP layer and backed by persisted models.
Paths: `user.py`, `methodology.py`, `benefit.py`

#### Data Model and Relationships
`models.py` is the central schema boundary, using SQLModel/SQLAlchemy and Pydantic-compatible models. Core relationships are: User-to-Methodology many-to-many through `UserMethodologyLink`; Methodology-to-Benefit many-to-many through `MethodologyBenefitLink`; User-to-Analysis and User-to-UserAudit one-to-many. These links make methodologies the bridge between assigned users and associated benefits.
Paths: `models.py`, `user.py`, `methodology.py`

#### Persistence Boundary
`db.py` owns database setup and session/connection concerns, isolating persistence from domain and endpoint code. The README identifies SQLite as the application database; checked-in Render SQL session files suggest database administration or inspection artifacts rather than runtime migrations.
Paths: `db.py`, `RenderDB.session.sql`, `Media-db Render.session.sql`

#### Analysis and Reporting Flow
Analysis records are associated with users, while report generation is separated into `reports.py`. The expected flow is user/domain data → analysis processing → rendered or downloadable report output. PDF and image libraries are present in the environment, consistent with report-generation capability, though implementation details are not available from the tree.
Paths: `analysis.py`, `reports.py`, `templates/new_analysis.html`

#### Runtime and Deployment
The service runs on Python 3 with FastAPI/Uvicorn, SQLModel/SQLAlchemy, Pydantic, and Jinja2. It is deployed on Render; GitHub Actions deployment automation is defined separately. The committed `myvenv/` includes runtime dependencies but should be treated as a bundled local environment, not core source architecture.
Paths: `.github/workflows/deploy.yml`, `requirements.txt`, `myvenv/pyvenv.cfg`

Main entry points: [`main.py`](https://github.com/iv4n-0v/project_social_medi4/blob/main/main.py) (FastAPI app), [`models.py`](https://github.com/iv4n-0v/project_social_medi4/blob/main/models.py) (SQLModel schema), [`analysis.py`](https://github.com/iv4n-0v/project_social_medi4/blob/main/analysis.py) (Analysis processing), [`user.py`](https://github.com/iv4n-0v/project_social_medi4/blob/main/user.py) (User management)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_presentation["HTTP &amp; Views"]
  node_app{{"FastAPI app<br/>ASGI entry<br/>[main.py]"}}
  node_templates["Jinja templates<br/>server-rendered views<br/>[base.html]"]
end

subgraph group_domain["Domain Services"]
  node_user["User management<br/>domain module<br/>[user.py]"]
  node_methodology["Methodology management<br/>domain module<br/>[methodology.py]"]
  node_benefit["Benefit management<br/>domain module<br/>[benefit.py]"]
  node_analysis["Analysis processing<br/>domain module<br/>[analysis.py]"]
  node_reports["Report generation<br/>report module<br/>[reports.py]"]
end

subgraph group_data["Persistence"]
  node_models["SQLModel schema<br/>data models<br/>[models.py]"]
  node_user_methodology["User–Methodology link<br/>many-to-many link<br/>[models.py]"]
  node_methodology_benefit["Methodology–Benefit link<br/>many-to-many link<br/>[models.py]"]
  node_db["Database sessions<br/>persistence setup<br/>[db.py]"]
  node_sqlite[("SQLite database")]
end

subgraph group_delivery["Delivery"]
  node_requirements["Python dependencies<br/>runtime manifest<br/>[requirements.txt]"]
  node_deploy["Render deployment<br/>CI/CD workflow<br/>[deploy.yml]"]
end

node_app -->|"routes requests to"| node_user
node_app -->|"routes requests to"| node_methodology
node_app -->|"routes requests to"| node_benefit
node_app -->|"routes requests to"| node_analysis
node_app -->|"invokes"| node_reports
node_app -->|"renders"| node_templates
node_user -->|"uses"| node_models
node_methodology -->|"uses"| node_models
node_benefit -->|"uses"| node_models
node_analysis -->|"stores analyses"| node_models
node_analysis -->|"supplies analysis data"| node_reports
node_models -->|"defines"| node_user_methodology
node_models -->|"defines"| node_methodology_benefit
node_user_methodology -.->|"methodology bridges"| node_methodology_benefit
node_models -->|"persists through"| node_db
node_db -->|"connects to"| node_sqlite
node_requirements -.->|"provides runtime"| node_app
node_deploy -->|"deploys"| node_app

click node_app "https://github.com/iv4n-0v/project_social_medi4/blob/main/main.py"
click node_templates "https://github.com/iv4n-0v/project_social_medi4/blob/main/templates/base.html"
click node_user "https://github.com/iv4n-0v/project_social_medi4/blob/main/user.py"
click node_methodology "https://github.com/iv4n-0v/project_social_medi4/blob/main/methodology.py"
click node_benefit "https://github.com/iv4n-0v/project_social_medi4/blob/main/benefit.py"
click node_analysis "https://github.com/iv4n-0v/project_social_medi4/blob/main/analysis.py"
click node_reports "https://github.com/iv4n-0v/project_social_medi4/blob/main/reports.py"
click node_models "https://github.com/iv4n-0v/project_social_medi4/blob/main/models.py"
click node_user_methodology "https://github.com/iv4n-0v/project_social_medi4/blob/main/models.py"
click node_methodology_benefit "https://github.com/iv4n-0v/project_social_medi4/blob/main/models.py"
click node_db "https://github.com/iv4n-0v/project_social_medi4/blob/main/db.py"
click node_requirements "https://github.com/iv4n-0v/project_social_medi4/blob/main/requirements.txt"
click node_deploy "https://github.com/iv4n-0v/project_social_medi4/blob/main/.github/workflows/deploy.yml"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app,node_templates toneBlue
class node_user,node_methodology,node_benefit,node_analysis,node_reports toneAmber
class node_models,node_user_methodology,node_methodology_benefit,node_db,node_sqlite toneMint
class node_requirements,node_deploy toneRose
```

## Components

### HTTP & Views

- [FastAPI app](https://github.com/iv4n-0v/project_social_medi4/blob/main/main.py): ASGI entry · Application composition and request routing. · `main.py`
- [Jinja templates](https://github.com/iv4n-0v/project_social_medi4/blob/main/templates/base.html): server-rendered views · Shared layout plus list, create, and edit pages. · `templates/base.html`

### Domain Services

- [User management](https://github.com/iv4n-0v/project_social_medi4/blob/main/user.py): domain module · `user.py`
- [Methodology management](https://github.com/iv4n-0v/project_social_medi4/blob/main/methodology.py): domain module · `methodology.py`
- [Benefit management](https://github.com/iv4n-0v/project_social_medi4/blob/main/benefit.py): domain module · `benefit.py`
- [Analysis processing](https://github.com/iv4n-0v/project_social_medi4/blob/main/analysis.py): domain module · Processes analyses associated with users. · `analysis.py`
- [Report generation](https://github.com/iv4n-0v/project_social_medi4/blob/main/reports.py): report module · Produces rendered or downloadable analysis reports. · `reports.py`

### Persistence

- [SQLModel schema](https://github.com/iv4n-0v/project_social_medi4/blob/main/models.py): data models · Defines entities and relationship link models. · `models.py`
- [User–Methodology link](https://github.com/iv4n-0v/project_social_medi4/blob/main/models.py): many-to-many link · `models.py`
- [Methodology–Benefit link](https://github.com/iv4n-0v/project_social_medi4/blob/main/models.py): many-to-many link · `models.py`
- [Database sessions](https://github.com/iv4n-0v/project_social_medi4/blob/main/db.py): persistence setup · Owns database setup and session handling. · `db.py`
- **SQLite database**: database

### Delivery

- [Python dependencies](https://github.com/iv4n-0v/project_social_medi4/blob/main/requirements.txt): runtime manifest · `requirements.txt`
- [Render deployment](https://github.com/iv4n-0v/project_social_medi4/blob/main/.github/workflows/deploy.yml): CI/CD workflow · `.github/workflows/deploy.yml`

## Connections

- FastAPI app → User management: routes requests to
- FastAPI app → Methodology management: routes requests to
- FastAPI app → Benefit management: routes requests to
- FastAPI app → Analysis processing: routes requests to
- FastAPI app → Report generation: invokes
- FastAPI app → Jinja templates: renders
- User management → SQLModel schema: uses
- Methodology management → SQLModel schema: uses
- Benefit management → SQLModel schema: uses
- Analysis processing → SQLModel schema: stores analyses
- Analysis processing → Report generation: supplies analysis data
- SQLModel schema → User–Methodology link: defines
- SQLModel schema → Methodology–Benefit link: defines
- User–Methodology link → Methodology–Benefit link: methodology bridges
- SQLModel schema → Database sessions: persists through
- Database sessions → SQLite database: connects to
- Python dependencies → FastAPI app: provides runtime
- Render deployment → FastAPI app: deploys
