How pk13055/effective-giggle works
This project is an online judge system called “Assignment-DOJE” that is used to host programming problems, allow user registrations (as solvers or setters), and process problem submissions with corresponding error/success checks. It is a full-stack web application built primarily using Python (with Flask as its web framework), with static assets (CSS, JavaScript) provided by MaterializeCSS and jQuery. There are also various generator scripts to populate the database with sample users, problems, or comments.
Main Components
• Client/Browser Frontend:
• Represents the user-facing interface where users interact.
• Managed by HTML templates (Jinja2 files under app/templates) and static assets such as CSS/JS from MaterializeCSS, jQuery, and Prism.
• Web Server/Reverse Proxy:
• Nginx serves as the front-end web server. It handles incoming HTTPS requests using SSL, serves static files, and forwards dynamic requests to the application server using uWSGI.
• Application Server:
• uWSGI is used to run the Flask application.
• The Flask application structure resides in the “app” directory. Notice submodules (Home, Problem, User, Comments, Checks, and specialized modules like flask_cas for single sign-on support).
• Business Logic Layer:
• The “controllers” and “helper” modules in each subdirectory (app/Home, app/User, app/Problem, etc.) represent the business logic and endpoint handlers.
• There is also a “models.py” that likely defines data relationships.
• Data Storage:
• The SQLite database file (safe.db) stored at the project root acts as the repository for persistent data (users, problems, submissions, etc.).
• Additionally, “Datasets” provide auxiliary data (emails, names, tags) that may be used during problem generation or user creation.
• Code Generation/Seed Scripts:
• Generator scripts (located in the “genrators” directory) such as comment_gen.py, problem_gen.py, and user_gen.py are used to populate the database with sample data.
• File Uploads and User Submitted Data:
• The “uploads” directory handles user submissions, test cases, problem texts, editorials, and solution files.
• External Libraries/Dependencies:
• Static libraries like jQuery, MaterializeCSS, and Prism.
• Flask’s own modules including flask_cas for authentication.
Relationships and Interactions
• A user interacts via a browser with the static content (HTML/CSS/JS) rendered using Jinja2 templates.
• The browser sends HTTP(S) requests to Nginx, which routes them:
• Requests for static assets are served directly.
• Dynamic requests are proxied to uWSGI.
• uWSGI runs the Flask app, calling appropriate controller methods (e.g., for Home, User, Problem, Comments).
• Controllers in the app forward business logic calls to helper functions or the problem_maker/user_maker modules to process logic (like generating or solving problems).
• Data read/write interactions are handled through “models.py” by communicating with the safe.db database.
• Separate modules handle problem generation and evaluation (for example, in app/Generators and app/Solver) to compile and run user programs, capture input/output, and error messages.
• The “flask_cas” module facilitates authentication and routing for single sign-on.
Architectural Patterns and Design Principles
• Modular Separation: Each functional area is split into its own module (e.g., Home, User, Problem, Comments) with controllers and helpers, promoting separation of concerns.
• MVC Inspiration: While not strictly MVC, the structure divides presentation (templates), business logic (controllers/helpers), and data (models/database).
• Reverse Proxy and Application Server Separation: Using Nginx and uWSGI clearly delineates concerns for security, static asset serving, and request load balancing.
• Extensibility & Configuration:
• The presence of separate generator scripts and clearly identified configuration files (config.py, uuwsgi.ini, uwsgi.ini) support easy scalability and customization.
Key Technologies and Frameworks
• Python (with Flask) – primary backend framework.
• uWSGI – for deploying the Flask app.
• Nginx – reverse proxy and static asset server.
• SQLite (or similar relational DB) – for storage (safe.db).
• MaterializeCSS, jQuery, Prism – for frontend UI design.
• Additional components like flask_cas for authentication.
• Clear labels:
• “Browser/Client UI”
• “Nginx (SSL Termination & Static File Server)”
• “uWSGI Application Server”
• “Flask Application” with submodules (Controllers: Home, User, Problem, Comments; Helpers; Models)
• “Database (safe.db)” and “Datasets”
• “Upload Storage” for problem texts, submissions, images
• “Generator Scripts” for seeding users, problems, comments
• “External Libraries” such as MaterializeCSS and jQuery (could be a note or grouped with Browser UI)
• From Browser to Nginx (requests for both static and dynamic content).
• From Nginx to uWSGI (dynamic request forwarding).
• Between Flask controllers and the Database.
• Between Flask modules and external authentication & file services.
• Visual Distinctions:
Detailed Execution
• “Uploads” directory as a shared resource accessible by the Flask app.
• Optionally, sketch out how generator scripts tie into the database seeding process (these are typically run as one-off commands).