How iv4n-0v/project_social_medi4 works
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 FastAPI app · models.py SQLModel schema · analysis.py Analysis processing · user.py User management
Components 14
HTTP & Views
- FastAPI app · Application composition and request routing.
main.py - Jinja templates · Shared layout plus list, create, and edit pages.
templates/base.html
Domain Services
- User management
user.py - Methodology management
methodology.py - Benefit management
benefit.py - Analysis processing · Processes analyses associated with users.
analysis.py - Report generation · Produces rendered or downloadable analysis reports.
reports.py
Persistence
- SQLModel schema · Defines entities and relationship link models.
models.py - User–Methodology link
models.py - Methodology–Benefit link
models.py - Database sessions · Owns database setup and session handling.
db.py - SQLite database
Delivery
- Python dependencies
requirements.txt - Render deployment
.github/workflows/deploy.yml
Connections 18
- 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