DOC App Structure Overview
This section provides an overview of the application structure, including the GitHub workflows and the organization of the application code.
GitHub Workflows
• checks.yml: Automates the process of logging into Docker Hub, and runs commands to test and lint the application using GitHub Actions.
• docker-compose.yml: Contains commands, environment variables, and port configurations for the application.
• Dockerfile: Specifies the operating system requirements and installation steps for the application.
• requirements.dev.txt: Lists the libraries used for development purposes.
• requirements.txt: Lists the libraries required by the application in the production environment.
App Structure
/app
• settings.py: Contains all the application configurations, including database settings, middleware, installed apps, and more.
• tests.py: File dedicated to unit and integration tests for the application.
/core
• management/wait_for_db.py: A utility that ensures PostgreSQL is ready before Docker Compose builds the application, addressing timing discrepancies.
• migrations/: This directory contains database migrations generated by the makemigrations command in Django. To apply these changes, follow these steps:
1. Ensure the database interface is configured in settings.py.
2. Define models and migrations appropriately for the project.
3. Run the migrate command to apply the migrations.
• models.py: Defines the data models; each class represents a database table, with class attributes mapping to the table columns.
• templates/: Directory where all HTML files are stored.
• tests/: Contains unit tests created to validate the application functions.
/licao (Lesson)
• serializers.py: Responsible for converting lesson-related model data into formats suitable for API requests and responses. Key functions include:
1. Data Conversion: Transforms model data into JSON or other formats for API consumption and converts incoming data into usable Python objects.
2. Data Validation: Implements custom validations to ensure received data is correctly formatted before saving it to the database.
3. Basic Structure: A serializer typically inherits from serializers.ModelSerializer or serializers.Serializer, specifying which fields to serialize.
• views.py: Handles HTTP requests related to lessons, returning appropriate responses. It defines the logic for processing client requests made to specific URLs in the application.
/user
• Follows the same structure and logic as the lesson module.
manage.py
• The main entry point for running the entire application, executed through commands defined in docker-compose.
.dockerignore
• Specifies files and directories (like virtual environments) that should be ignored when building Docker images.
Admin Access
• Admin Login URL: http://127.0.0.1:8000/admin/login/?next=/admin/
• Login: [email protected]
• Password: ssssss