How om-mishra7/a-star works
Project type and purpose
• This is a monolithic full-stack web application (“A* – Community Competition Platform”) built on Flask.
• It serves dynamic HTML (via Jinja2 templates) and static assets, manages users/contests/problems/submissions, and integrates external services (Judge0, Google Gemini, OAuth2 provider, CDN).
File structure
• Root files: Dockerfile, vercel.json, requirements.txt, README.md → deployment and build config.
• backend/main.py → single entry point for routing, controllers, business logic.
• backend/templates/… → Jinja2 views organized by page/function (problems, contests, admin forms, private includes).
• backend/static/… → CSS, JavaScript (including Monaco editor), image assets.
• No separate “models” folder → data-access likely encapsulated in service functions within main.py.
Relationships and data flow
• Browser → HTTP(S) → Flask routes:
– Frontend routes return HTML + static assets (templates + CSS/JS).
– AJAX/Fetch calls to backend API (submissions, user-data endpoints).
• Flask ↔ Redis: session read/write and cache common data (announcements, leaderboards).
• Flask ↔ MongoDB: CRUD on users, problems, contests, submissions, leaderboards.
• Flask → OAuth2 Provider: redirect/login callback to exchange code for user info.
• Flask → Judge0 CE API (async code execution):
– POST code, receive token → store submission in MongoDB → poll with token → update status.
• Flask → Google Gemini API: generate problems, reports, user summaries.
• Flask → CDN API: upload/manage profile pictures.
Architectural patterns & principles
• Layered (MVC-style):
– Controllers (Flask routes in main.py),
– Views (Jinja2 templates + static),
– Models/Services (data-access + business logic in functions).
• Context processors inject global data into views.
• Middleware (@after_request) for headers (caching/static assets).
• Rate limiting & similarity checks in submission flow.
1. Sketch a high-level block for each main component.
4. Inside the Flask block, subdivide by major feature areas: Auth, Submissions, Contests, AI, Context.
6. Review to ensure every external service, datastore, and critical module is represented.