How codemini100/mini-dropbox works
Main Components
• Client/Consumer: This represents any API consumer (e.g., a mobile/web client, API testing tool like Postman). Although there is no separate “frontend” directory, the client is abstracted by the REST API endpoints.
• Web Server/Application Layer:
• The main entry point is app.py (and demo_app.py for demo purposes) which ties everything together using Flask.
• This layer registers Flask Blueprints for each major module:
▫️ /auth for user authentication
▫️ /files for file management (upload, download, listing)
▫️ /sync for file versioning and syncing
▫️ /share for file sharing
• Service/Controller Layers:
• Each module (auth, files, sync, sharing) splits logic into a controller and a service. Controllers (e.g., auth_controller.py, file_controller.py) define the API endpoints while Services (e.g., auth_service.py, file_service.py, etc.) handle business logic.
• Config & Utility Components:
• config.py holds system settings like database URI, storage paths, and secret keys.
• The utils directory includes common functionalities such as logging (logger.py) and authentication helpers (auth_helpers.py).
• Database and Storage (External Dependencies):
• Although only pseudo-code is provided for DB operations, consider a database that stores user records, file metadata, sync version info, and share tokens.
• A file storage service or local file system is used to store the actual files.
Relationships and Interactions
• The Client sends HTTP requests (e.g., signup, login, file upload) to the Flask server.
• The Flask server routes requests to the appropriate Blueprint (auth, files, sync, sharing).
• Each Controller calls its corresponding Service to process business logic:
• For user management, the auth module hashes/verifies passwords.
• For file management, the files module handles saving a file and returning its metadata.
• The sync module provides endpoints for tracking file updates and resolving conflicts.
• The sharing module creates and validates share links.
• The Config module is used by different services to retrieve environment-specific settings.
• Utility components are accessed where needed to log events or assist with user authentication.
Fundamental Architectural Patterns and Design Principles
• Modularity: The project is split into discrete modules (auth, files, sync, sharing) that communicate through well-defined APIs.
• Separation of Concerns: Controllers handle HTTP request/response logic, while services encapsulate business rules and interactions with external systems (DB, file storage).
• Blueprint Method (in Flask): This pattern is used to keep the codebase scalable. Each major functionality is isolated in its own blueprint.
• Reusability: Utility components and configuration settings are centralized so that changes in one area (like switching the storage path) propagate throughout the app.