How vladimirvereshchagin/scheduler works
Main Components
• Frontend: The user-facing part of the application (found in the “web” directory with HTML, CSS, and JavaScript files). This is the web interface where users interact with the system.
• Backend/API: The core of the application built in Go. The entry point is in “cmd/main.go”, and it handles HTTP requests, routing (via internal/app/routes.go), and middleware setup.
• Authentication Module: Implemented in “internal/auth/jwt.go”, providing JWT token creation and validation to secure API endpoints.
• Business Logic & Services: Found in “internal/services” (such as task_service.go) that encapsulate the application’s core logic for managing tasks.
• Data Access Layer: Consists of “internal/models” (e.g., task.go) for data modeling and “internal/repository” (repository.go) for SQLite database interactions.
• Configuration: Managed via “internal/config/config.go” for reading environment variables and loading configuration settings.
• Time Utilities: In “internal/timeutils/date.go”, which provides helper functions likely used by services or scheduling logic.
• Database: SQLite is managed within “data” (for the persistent file, e.g., scheduler.db) and is auto-created at launch if not present.
• Testing Components: The “tests” directory contains the integration and unit tests, with a dedicated test configuration in “tests/settings.go” and a helper script “run-tests.sh”.
Interactions
• The Frontend (web interface) sends HTTP requests (possibly via AJAX or form submissions) to the RESTful backend.
• The Backend (HTTP server initialized in cmd/main.go) routes requests via defined routes (inside internal/app/routes.go) to various handlers in internal/app/handlers.go.
• Authentication: Requests pass through middleware (set up in internal/app/middleware) that checks for valid JWT tokens (as implemented in internal/auth).
• Once authenticated, requests are processed by the backend which calls into business logic (internal/services) that in turn relies on data models (internal/models) and interacts with the SQLite database via the repository layer (internal/repository).
• Utility functions like date formatting (in internal/timeutils) are used by services when scheduling or managing task dates.
• Additionally, configuration settings loaded by internal/config ensure environment variables (such as port, database file path, and JWT password) are correctly applied.
• Docker and CI/CD: Dockerfile, docker-compose.yml, and GitHub Actions workflows indicate containerized deployment and automated testing/builds, which should be depicted as part of the deployment pipeline.
Architectural Patterns and Design Principles
• Separation of Concerns: The project clearly separates the presentation layer (frontend in “web”), the business logic layer (internal/services), and the data access layer (internal/models and internal/repository).
• RESTful API Design: Clear API endpoints are defined to handle CRUD operations for tasks.
• Middleware for Authentication: JWT-based authentication is centrally managed using middleware, promoting modular security.
• Containerization: With Docker support, the design emphasizes portability and scalability.
• Automated Testing & CI/CD: Robust testing support (with a dedicated tests folder and GitHub workflows) is key to reliability.
Relevant Technologies
• Go (primary language, with Go modules for dependency management)
• SQLite (database via the modernc.org/sqlite driver)
• Docker (for containerization and deployment)
• GitHub Actions and Pre-commit Hooks (for CI/CD and code quality)
• JWT for Authentication
Final Recommendations
• Do not hesitate to break the system into as many components as the application’s structure allows; the more granular the depiction, the easier it will be to understand the architecture.
• Every component is annotated with clear labels, and include reference to the relevant directories (e.g., “internal/app – Routes and Handlers”, “internal/auth – JWT handling”, “internal/services – Business Logic”).