How lugvitc/pwncore works
Main Components
• API Layer: Represent FastAPI as the central HTTP server. Mark that the FastAPI app facilitates auto-generated documentation (via /docs and /redoc endpoints).
• Routes: Distinguish the different sets of routes such as:
– Authentication routes (admin.py, auth.py)
– CTF functionality routes (in the ctf sub-directory; e.g., start, pre_event)
– Other endpoints like leaderboard and team management.
• Business Logic / Controllers: Indicate that the actual handling of logic is split into different modules. For instance, container management (containerASD.py) and additional route-specific business logic.
• Models/ORM Layer: Emphasize using Tortoise-ORM with clearly defined models (user, container, ctf, pre_event). Show that these models handle data persistence.
• Configuration: Include a configuration block (from config.py) responsible for setting parameters such as the database URL and Docker service URL.
• Docker / Container Integration: Highlight that the platform can launch or manage Docker containers (see container modules and Docker configurations in both config.py and Dockerfile/docker-compose.yaml).
• Testing: Although not a runtime component, include an indication of testing infrastructure using tox and tests (which are designed to validate critical functionalities).
Relationships and Interactions
• Route to Controller: Demonstrate how each route (e.g., authentication, leaderboard, CTF routes) maps to underlying business logic modules.
• External Services: If Docker functionality is enabled, show that certain routes invoke container management services, communicating with the Docker engine (or a simulated Docker endpoint using the provided Docker URL).
• Documentation: Mention that FastAPI’s auto-generated OpenAPI docs are a natural byproduct of well-documented route implementations.
Architectural Patterns & Design Principles
• Layered Architecture: The project separates concerns into configuration, routing, business logic, and models, making it easier to maintain.
• RESTful API Principles: Since the service uses FastAPI, the routes follow REST-like conventions to expose endpoints for various CTF functionalities.
• Dependency Injection (implicit): While not explicitly detailed, the project likely uses dependency injection patterns (common in FastAPI) to inject settings and database connections.
• Containerization: The Dockerfiles and docker-compose.yaml files indicate an architecture that is designed with both local and containerized execution in mind.