Top-Level Structure
The application follows a standard Flask layout with additional directories for assets, tests, and deployment:Entry Point
The application is initialized inapplication.py:
create_app().
Application Directory (app/)
The app/ directory contains all application code organized by function:
Core Files
__init__.py - Application Factory
The main application factory that:
- Initializes Flask extensions (CSRF, login manager, metrics)
- Registers blueprints
- Sets up error handlers
- Configures Jinja2 templates
- Adds template filters
- Registers before/after request handlers
create_app(application)- Main factory functionsetup_blueprints(application)- Registers all blueprintsregister_errorhandlers(application)- Sets up error handlinginit_jinja(application)- Configures template engine
config.py - Configuration
Defines configuration classes for different environments:
Assets Directory
Frontend assets are organized by type:Templates Directory
Jinja2 templates are organized by function:Utils Directory
Utility modules provide shared functionality:S3 Client
S3 integration for file storage:File Count
The application contains approximately 145 Python files across all directories, demonstrating a substantial codebase with clear separation of concerns.Design Principles
Separation of Concerns
- Views handle HTTP requests and responses
- Models represent domain objects and data
- API Clients communicate with backend services
- Templates handle presentation
- Utilities provide shared functionality
Blueprint Architecture
The application uses Flask blueprints to organize routes:main- Primary application routesjson_updates- JSON endpoints for async updatesno_cookie- Routes that don’t set cookies (previews)status- Health check and status endpoints
Configuration Management
Environment-based configuration using environment variables and config classes allows the same codebase to run in development, staging, and production.Asset Management
Static assets are fingerprinted for cache busting and served efficiently using Flask’s asset handling with CDN support.Next Steps
- Flask Blueprints - Learn about the blueprint structure
- Models - Explore the data models
- API Clients - Understand API integration