How rauladse/construction_map works
Project Type and Purpose
• This is a full-stack web application for managing construction projects by viewing and overlaying construction maps, creating pinpoint events, and managing project data.
• The backend is built with Python (FastAPI) and uses PostgreSQL as its database. The frontend, built in React, is in development.
• Key features include user authentication, project management, map overlays, event management, and data export.
Analyzing the File Structure
• The project is clearly separated into multiple areas:
• “backend/”: Contains the FastAPI backend code.
• The “app/” folder holds core application code with subdirectories for:
▪ api (endpoints and versioning, e.g., api/v1/ with endpoints for maps, events, authentication, etc.)
▪ core (application configuration and security settings)
▪ db (database configuration and connection details)
▪ models (SQLAlchemy models for various entities like event, map, project, user)
▪ schemas (Pydantic schemas for request/response validation)
▪ services (business logic for managing authentication, events, maps, projects)
• “backend/migrations/”: For Alembic database migration scripts.
• “backend/tests/”: Contains tests to verify backend functionality.
• “frontend/”: Although still coming online, this contains the React code for the user interface with organized components, pages, assets, and styles.
• Additional scripts and configuration files (e.g., run_server.py, start_servers.sh, webpack.config.js) hint at deployment and build processes.
Key Components
a. Backend Components:
• FastAPI Application: Represent the core API that handles incoming HTTP requests. Show that it uses dependency injection (e.g., using routes, endpoint files, and versioning under “api/v1”).
• API Endpoints: Each specific endpoint (maps, events, auth, etc.) under “app/api/v1/endpoints” (and similarly under “backend/app/api/v1/endpoints”) should be represented as part of the API layer.
• Data Layer:
• Database Access: Illustrate the “db” folder and indicate that it uses SQLAlchemy for database interactions.
• Models & Schemas: Capture the models (database structure) and Pydantic schemas (data validation) that define the data structure.
• Core Application Settings: Include components for configuration and security (from “core/config.py” and “core/security.py”).
• Migrations: Mention the Alembic migration system that ties into the database changes.
b. Frontend Components:
• React Application: Even though it is “coming soon,” show that the frontend is structured into components, pages (such as LoginPage, MapViewer, ProjectList), services (authService, eventService, mapService), and assets.
• User Interface: Represent consistent elements like navigation, modal dialogs for event creation, map viewing, notifications, and project management.
c. Auxiliary Scripts & Deployment:
• Deployment/utility scripts (e.g., start_servers.sh, stop_servers.sh) which indicate how the system is started and managed.
• External dependencies like Leaflet/OpenLayers for map visualization.
• Environment and configuration files (e.g., .env file for sensitive settings).
Relationships and Interactions
• Users make HTTP requests from the frontend to the FastAPI backend.
• The API layer processes these requests, invoking services to handle business logic.
• Services interact with the database layer (SQLAlchemy models and PostgreSQL) to retrieve or update data.
• Authentication/authorization modules validate user credentials.
• The map endpoints and services interface with map visualization libraries (Leaflet/OpenLayers) though these are likely integrated in the future frontend portion.
• Versioning in your API (e.g., v1 endpoints) and note that there is clear modular separation.
Architectural Patterns and Design Principles
• The Backend employs a layered (or “onion”) architecture with clear separations for API routing, business logic, and data access.
• RESTful design of API endpoints.
• Usage of dependency injection (e.g., through FastAPI deps) and modular design for separating concerns.
• If applicable, mention that the future integration of the React frontend with the backend hints at a modern full-stack decoupled architecture.