How rexaintreal/syna works
Project type and purpose
• Project Type: Full-stack social music web application
• Purpose: Let users log in with Spotify, analyze their listening habits, and match them with other users via a cosine-similarity algorithm
File structure
• Top-Level Files
– app.py: Flask application entry point; defines routes, OAuth callbacks, renders templates
– clean.py: Utility script (likely for maintenance or cleanup tasks)
– requirements.txt: Python dependencies (Flask, spotipy or requests, SQLite driver, etc.)
• Directories
– static/assets: CSS (Tailwind), images (logo, screenshots), webmanifest, Spotify branding assets
– templates: Jinja2 HTML templates (login, setup, dashboard, top-charts, settings, feedback, privacy, terms)
– utils: Business-logic modules
· db.py: Database connection and ORM or raw SQL helpers for SQLite
· matcher.py: Core cosine-similarity algorithm to compare user music profiles
· match_cache.py: Caching layer to store computed matches and reduce recomputation
• Configuration & Deployment
– .gitignore, LICENSE, README.md
– Hosting: PythonAnywhere; environment variables for Spotify OAuth in a .env file
README for additional insights
• Tech Stack:
– Frontend: HTML + Tailwind CSS
– Backend: Flask (Python 3.8+)
– DB: SQLite
– Auth: Spotify OAuth 2.0
– Algorithm: Cosine Similarity
• Features: user profiles, top-charts page, matching, settings, feedback
a. Main components
1. User & Browser (UI Client)
2. Frontend Layer (templates + Tailwind assets served by Flask)
3. Flask Application Server
– Route Handler (app.py)
– Business Logic (utils/matcher.py, utils/match_cache.py)
– Data Access Layer (utils/db.py)
4. SQLite Database
5. External Service: Spotify API & OAuth2 Provider
6. Hosting Environment: PythonAnywhere (optional annotation)
b. Relationships & interactions
• User/browser → HTTP(S) → Flask Server
• Flask Server ↔ SQLite (read/write user profiles, top-charts, cached matches)
• Flask Server ↔ Spotify API (OAuth handshake, fetch listening data, refresh tokens)
• Matcher module reads from DB and calculates similarity; writes output back to DB or cache
• Server renders dynamic pages via Jinja2 templates injecting data from DB & match results
c. Architectural patterns & design principles
• MVC-style separation:
– Views: Jinja2 templates under /templates
– Controllers: Flask route functions in app.py
– Model/Data Access: utils/db.py
• Layered architecture: Presentation, Application Logic, Data Access, External Services
• Caching layer (utils/match_cache.py) to improve performance of expensive similarity computations
d. Key technologies & frameworks
• Flask 2.x (WSGI web framework)
• Tailwind CSS for styling
• SQLite (file-based relational DB)
• Spotify OAuth 2.0 / REST API
• Python libraries: spotipy or requests, numpy or custom math functions for cosine similarity
Detail without over-fragmentation
• Every logical component: UI, static assets, route handlers, matcher/cache, DB, external API
• Do not delve into individual CSS classes or every single template—group them as “UI layer”
• Caching layer separately from raw matching logic to highlight performance design