This template outlines a modular, scalable architecture for data-driven applications. Examples of each component are available in the database under Base<Component>.
<aside>
<img src="/icons/copy_red.svg" alt="/icons/copy_red.svg" width="40px" />
You can click the “duplicate” icon in the top right to get started with your own app
</aside>
Core Components
- Models: Define data structures and business logic.
- Located in
src/models/
- Use dataclasses or similar for clean, type-hinted definitions
- Repositories: Abstract data access and storage.
- Located in
src/repositories/
- Use abstract base classes to define interfaces
- Implement concrete classes for specific data sources (e.g., SQL, NoSQL)
- Services: Encapsulate business logic and orchestrate data flow.
- Located in
src/services/
- Use repositories to access data
- Implement complex operations and validations
- Application Layer: Handle user interactions (e.g., web forms, API endpoints).
- Use services to process requests and manage data
Key Principles
- Separation of Concerns: Each component has a distinct responsibility.
- Dependency Inversion: High-level modules depend on abstractions.
- Single Responsibility: Each class has one primary purpose.
- Open/Closed: Extensible without modifying existing code.
Benefits
- Modularity: Easy to maintain and extend.
- Testability: Components can be tested in isolation.
- Flexibility: Easy to swap implementations (e.g., change database).
- Scalability: Clear structure for growing applications.
Implementation Steps
- Define core domain models.
- Create repository interfaces and implementations.