How tgt073/tfg works
Project Type and Purpose
• This is a full‑stack web application (“TFG”) that provides movie recommendations.
• Backend: Python + Flask, several recommendation‑engine modules.
• Frontend: Jinja2 templates + static assets (CSS, images).
• Persistence: two SQLite databases (movies_genre.db, users.db).
• Auxiliary scripts: Evaluacion.py and ProbarSVD.py for evaluating algorithms offline.
Top‑Level Components
A. Web Client (Browser)
• Renders HTML from templates/ (index.html, login.html, dashboard.html, movie_detail.html, search_results.html, registrer.html).
• Loads static assets from static/style.css and static/imgs/.
B. Flask Application (app2.py)
• Entry point: defines routes (/, /login, /register, /dashboard, /movie/<id>, /search, etc.).
• Uses Flask, Jinja2, and SQLite (sqlite3 or an ORM).
• Imports recommendation modules from RecomendadoresPruebas/.
• Manages user sessions and form submissions.
C. Recommendation Engine Modules (RecomendadoresPruebas/)
• Contenido.py – Content‑based filtering.
• Items.py – Item‑based collaborative filtering.
• Usuarios.py – User‑based collaborative filtering.
• Modelo.py – Core model utilities (data loading, similarity metrics).
• Hybrid.py – Combines results from multiple recommenders.
D. Databases (database/)
• movies_genre.db – movie metadata, genres.
• users.db – user profiles, ratings.
E. Evaluation & Experimentation Scripts
• Evaluacion.py – runs offline tests, computes accuracy metrics.
• ProbarSVD.py – tests SVD‑based recommender performance.
F. Configuration & Dependencies
• .env – environment variables (e.g. Flask secret key, DB paths).
• requirements.txt – Flask, Jinja2, numpy, pandas, scikit‑learn, etc.
• .gitattributes, .idea (IDE settings).
Relationships & Data Flows
1. User action in Browser → HTTP request to Flask (app2.py).
2. Flask route handler → queries SQLite DB (users.db or movies_genre.db).
3. For recommendations, route calls one or more functions in RecomendadoresPruebas modules:
– e.g. Usuarios.get_recommendations(user_id) or
Hybrid.combine([...]).
4. Modules in RecomendadoresPruebas → internally load data from DB via Modelo.py utilities.
5. Recommendation results returned to Flask → passed into Jinja2 templates → rendered HTML.
6. Static assets served alongside HTML.
7. Evaluation scripts (Evaluacion.py, ProbarSVD.py) run offline: import modules from RecomendadoresPruebas, load DBs, output metrics to console or files.
Execution Flow (Numbered Sequence)
1. User navigates to /login → app2.py renders templates/login.html.
2. On login POST → app2.py validates against users.db.
3. Successful login → redirect to /dashboard.
4. app2.py calls Hybrid.recommend_for(user_id) → internally calls Contenido, Items, Usuarios modules → each loads data via Modelo → queries DBs.
5. Combined recommendations returned → passed to dashboard.html.
6. User clicks on a movie → GET /movie/<id> → app2.py loads details from movies_genre.db → renders movie_detail.html.
7. Search flow similarly handled via a search route + search_results.html.
Bringing It All Together
• Sketch four horizontal layers:
1. Client Layer (Browser)
2. Presentation Layer (Flask/app2.py + templates + static)
3. Business Logic Layer (RecomendadoresPruebas modules)
4. Data Layer (SQLite DBs)
• Captures every folder and file in this version of the repo.
• Shows module interactions, data flows, and DB connections.
• Highlights external libraries and configuration.
• Illustrates both the runtime web‑app flow and the offline evaluation processes.