How kajilabteam/walking-information-storage-server works
Project Type and Purpose
• This is a backend service for accumulating walking data and estimating current position information.
• The project follows a layered or Clean Architecture style with clear divisions between presentation, application, domain, and infrastructure layers.
Main Components from the File Structure
• Docker Configuration:
• docker/postgres: Contains Dockerfile and SQL migration/demo scripts to set up the Postgres database container.
• docker/server: Contains the Dockerfile for running the application server container.
• Server Directory (backend application):
• Presentation Layer: Under server/presentation/handlers. This layer exposes REST API endpoints (e.g., health_check_handler, start_walking_handler) that handle incoming HTTP requests.
• Application Layer: Under server/application where DTOs, services (health_check_service, move_pedestrian_service, etc.), and error handling logic reside.
• Domain Layer: Located in server/domain. Contains the business logic with models (for particles, floor_maps, walking parameters) and domain-specific errors. This layer encapsulates the core domain knowledge.
• Infrastructure Layer: In server/infrastructure. This handles lower-level concerns like database connections, repository implementations, and integration with external file services.
• Configuration & Utility Files:
• Files such as .env.example, configuration files in server/config, and utility modules under server/utils are used to manage environment settings and helper methods.
• Development and Deployment Tools:
• Makefile for command-line tasks, pre-commit configuration, and various Docker-related scripts.
Relationships and Data Flow
• Client requests hit the Presentation Layer (handlers) which then delegate to the Application Layer’s services.
• The Application Services encapsulate use-case logic (e.g., starting or finishing a walking session, moving a pedestrian) and interact with the Domain Layer where core business models and logic are enforced.
• Persistence and Repository patterns are used to abstract data access. The Infrastructure Layer (with specific repository implementations) communicates with the Postgres database container that is set up by the Docker Compose configuration.
• The application’s error handling flows from the Domain and Application layers up to the Presentation layer to provide appropriate responses.
Architectural Patterns and Important Technologies
• Layered (or Clean) Architecture: Separates concerns across presentation, application, domain, and infrastructure layers.
• Docker Containerization: The project uses separate containers for the server, Postgres database, and Schemaspy. Docker Compose orchestrates these containers.
• REST API: Exposed via uvicorn and FastAPI (implied by uvicorn invocation and standard Python practices).
• Database Migrations: SQL migration files in the docker/postgres directory indicate a structured approach to managing database schema evolution.