# mailtonskiran/vibe-coding architecture

> Architecture diagram of the GitHub repository mailtonskiran/vibe-coding, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mailtonskiran/vibe-coding
- Repository: https://github.com/mailtonskiran/vibe-coding

## Overview

1. **Overall shape**
   - This is a small, single-process Flask application for mutual fund portfolio management.
   - The core runtime is Python, with a server-rendered web UI plus JSON API endpoints.
   - Persistence is handled by a local SQLite database stored under `instance/mutual_funds.db`.

2. **Primary application boundary**
   - `app.py` is the main entry point and likely contains the Flask app, route handlers, request validation, and orchestration of database and recommendation logic.
   - The README’s listed endpoints indicate the app exposes both HTML pages and REST-style API routes from the same backend.

3. **Data layer**
   - SQLite is the only persistent datastore in the repository.
   - The `instance/` folder is the Flask-standard location for app-local state, and the database file there suggests the app uses a file-backed, single-node deployment model.
   - `dbview.py` appears to be an auxiliary utility for inspecting or querying the database during development.

4. **Domain data and initialization**
   - `populate_master_data.py` and `Python/data.csv` indicate the project includes a data-loading path for seeding master mutual fund data.
   - This likely supports lookup/reference data used by recommendation and portfolio functions rather than user-generated transactional data.

5. **Recommendation subsystem**
   - `RECOMMENDATION_LOGIC.md` suggests the recommendation engine is a distinct documented concern, probably mapping investor risk profile to fund selections.
   - The API endpoint `GET /api/recommendations/<investor_id>` is the main integration point for that logic.
   - Architecturally, this is the key business rule layer between investor profile data and fund catalog data.

6. **Portfolio and investor management**
   - The documented endpoints `POST /api/investors` and `POST /api/portfolios/<investor_id>` show two main domain entities: investors and portfolios.
   - Investor registration/profile management is the user identity and risk-profile boundary.
   - Portfolio creation/management is the investment container boundary that associates an investor to selected funds or holdings.

7. **Frontend composition**
   - The UI is currently a Flask template-based frontend, not the React frontend mentioned as future work in the README.
   - `templates/index.html` is the primary page template.
   - `static/css/style.css` and `static/js/main.js` provide client-side presentation and interaction, likely for form submission, API calls, and dynamic updates.

8. **Request/response flow**
   - A typical flow is: user interacts with the browser UI → browser loads the Flask-served HTML/JS/CSS → client submits investor or portfolio data to Flask API endpoints → Flask persists or reads from SQLite → responses are returned as JSON or rendered content.
   - Recommendation requests likely combine investor profile data and master fund data from the database to produce ranked fund suggestions.

9. **Supporting artifacts**
   - `FUNCTIONAL_REQUIREMENTS.md` and `SESSION_SUMMARY.md` are project documentation rather than runtime components.
   - They probably capture intended behaviors, design decisions, and implementation status, and are useful for understanding system boundaries but not part of the deployed architecture.

10. **Project constraints implied by the repo**
   - The app is local-first and file-backed, which means deployment and scaling are simple but stateful.
   - There is no evidence of external services, authentication providers, or background workers in this repository.
   - Historical analytics and real-time market integration are explicitly listed as future enhancements, so current architecture is likely focused on CRUD plus rule-based recommendations.

11. **What to draw in an architecture diagram**
   - Draw three main layers: browser UI, Flask application/API, and SQLite database.
   - Add a separate “data seed / master data import” path from CSV into the database.
   - Show the recommendation logic as a backend service/module inside the Flask application that reads investor profile data and fund master data.

12. **Important distinction**
   - Although the README mentions React, the checked-in structure does not show a React frontend; the implemented UI is template/static-file based.
   - For an accurate diagram, treat React as planned future architecture, not current architecture.

Main entry points: [`app.py`](https://github.com/mailtonskiran/vibe-coding/blob/main/app.py) (Flask app), [`instance/mutual_funds.db`](https://github.com/mailtonskiran/vibe-coding/blob/main/instance/mutual_funds.db) (SQLite DB), [`templates/index.html`](https://github.com/mailtonskiran/vibe-coding/blob/main/templates/index.html) (Index page), [`populate_master_data.py`](https://github.com/mailtonskiran/vibe-coding/blob/main/populate_master_data.py) (Seed loader)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_presentation["Presentation"]
  node_browser_ui["Browser UI<br/>web ui"]
  node_index_template["Index page<br/>template<br/>[index.html]"]
  node_client_js["Client JS<br/>frontend script<br/>[main.js]"]
  node_client_css["Stylesheet<br/>[style.css]"]
end

subgraph group_backend["Backend"]
  node_flask_app["Flask app<br/>server<br/>[app.py]"]
  node_html_routes["Pages<br/>route layer"]
  node_api_routes["API<br/>route layer"]
  node_recommendations{{"Recommendations<br/>business logic"}}
  node_investors["Investors<br/>domain model"]
  node_portfolios["Portfolios<br/>domain model"]
end

subgraph group_data["Data"]
  node_sqlite_db[("SQLite DB<br/>persistence<br/>[mutual_funds.db]")]
  node_seed_loader["Seed loader<br/>import script"]
  node_master_csv["Master data<br/>csv seed<br/>[data.csv]"]
end

subgraph group_tooling["Tooling"]
  node_dbview["DB view<br/>inspection tool<br/>[dbview.py]"]
  node_docs_logic["Logic notes<br/>documentation"]
end

node_browser_ui -->|"loads"| node_index_template
node_index_template -->|"uses"| node_client_js
node_index_template -->|"styles"| node_client_css
node_browser_ui -->|"requests"| node_flask_app
node_flask_app -->|"serves"| node_html_routes
node_flask_app -->|"exposes"| node_api_routes
node_api_routes -->|"manages"| node_investors
node_api_routes -->|"manages"| node_portfolios
node_api_routes -->|"calls"| node_recommendations
node_recommendations -->|"reads"| node_sqlite_db
node_recommendations -.->|"depends on"| node_master_csv
node_flask_app -->|"persists"| node_sqlite_db
node_seed_loader -->|"imports"| node_master_csv
node_seed_loader -->|"loads"| node_sqlite_db
node_dbview -->|"inspects"| node_sqlite_db
node_docs_logic -.->|"describes"| node_recommendations
node_client_js -->|"calls"| node_api_routes

click node_index_template "https://github.com/mailtonskiran/vibe-coding/blob/main/templates/index.html"
click node_client_js "https://github.com/mailtonskiran/vibe-coding/blob/main/static/js/main.js"
click node_client_css "https://github.com/mailtonskiran/vibe-coding/blob/main/static/css/style.css"
click node_flask_app "https://github.com/mailtonskiran/vibe-coding/blob/main/app.py"
click node_sqlite_db "https://github.com/mailtonskiran/vibe-coding/blob/main/instance/mutual_funds.db"
click node_seed_loader "https://github.com/mailtonskiran/vibe-coding/blob/main/populate_master_data.py"
click node_master_csv "https://github.com/mailtonskiran/vibe-coding/blob/main/Python/data.csv"
click node_dbview "https://github.com/mailtonskiran/vibe-coding/blob/main/dbview.py"
click node_docs_logic "https://github.com/mailtonskiran/vibe-coding/blob/main/RECOMMENDATION_LOGIC.md"

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_browser_ui,node_index_template,node_client_js,node_client_css toneBlue
class node_flask_app,node_html_routes,node_api_routes,node_recommendations,node_investors,node_portfolios toneAmber
class node_sqlite_db,node_seed_loader,node_master_csv toneMint
class node_dbview,node_docs_logic toneRose
```

## Components

### Presentation

Server-rendered UI and client-side assets

- **Browser UI**: web ui · User-facing entry point served by Flask
- [Index page](https://github.com/mailtonskiran/vibe-coding/blob/main/templates/index.html): template · Primary HTML template for the app · `templates/index.html`
- [Client JS](https://github.com/mailtonskiran/vibe-coding/blob/main/static/js/main.js): frontend script · Browser-side interaction and API calls · `static/js/main.js`
- [Stylesheet](https://github.com/mailtonskiran/vibe-coding/blob/main/static/css/style.css): stylesheet · UI styling for the template · `static/css/style.css`

### Backend

Flask application and domain logic

- [Flask app](https://github.com/mailtonskiran/vibe-coding/blob/main/app.py): server · Main application entry point · `app.py`
- **Pages**: route layer · Server-rendered page handlers
- **API**: route layer · JSON endpoints for investors, portfolios, and recommendations
- **Recommendations**: business logic · Investor-to-fund recommendation rules
- **Investors**: domain model · Investor profile and risk boundary
- **Portfolios**: domain model · Portfolio creation and management

### Data

Persistent store and seed inputs

- [SQLite DB](https://github.com/mailtonskiran/vibe-coding/blob/main/instance/mutual_funds.db): persistence · Local application database · `instance/mutual_funds.db`
- [Seed loader](https://github.com/mailtonskiran/vibe-coding/blob/main/populate_master_data.py): import script · Loads master fund data into the database · `populate_master_data.py`
- [Master data](https://github.com/mailtonskiran/vibe-coding/blob/main/Python/data.csv): csv seed · Reference fund data used for seeding · `Python/data.csv`

### Tooling

Development and inspection utilities

- [DB view](https://github.com/mailtonskiran/vibe-coding/blob/main/dbview.py): inspection tool · Utility for inspecting the database · `dbview.py`
- [Logic notes](https://github.com/mailtonskiran/vibe-coding/blob/main/RECOMMENDATION_LOGIC.md): documentation · Reference documentation for recommendation behavior · `RECOMMENDATION_LOGIC.md`

## Connections

- Browser UI → Index page: loads · Browser receives the rendered page shell
- Index page → Client JS: uses · Template includes client-side behavior
- Index page → Stylesheet: styles · Template uses shared styling
- Browser UI → Flask app: requests · User actions reach the Flask backend
- Flask app → Pages: serves · Renders pages for the UI
- Flask app → API: exposes · Provides JSON endpoints
- API → Investors: manages · Creates and reads investor profiles
- API → Portfolios: manages · Creates and reads portfolios
- API → Recommendations: calls · Recommendation endpoint delegates to business logic
- Recommendations → SQLite DB: reads · Uses stored investor and fund data
- Recommendations → Master data: depends on · Relies on seeded master fund catalog
- Flask app → SQLite DB: persists · Reads and writes application state
- Seed loader → Master data: imports · Consumes CSV seed data
- Seed loader → SQLite DB: loads · Populates the local database
- DB view → SQLite DB: inspects · Developer utility for querying the DB
- Logic notes → Recommendations: describes · Documents recommendation behavior
- Client JS → API: calls · Front end submits API requests
