Skip to content

Project structute #17

Description

@MRD2F

Recommended Project Structure for a Python Web API
myproject/

├── pyproject.toml
├── uv.lock
├── README.md
├── .gitignore
├── .env # Environment variables (never commit in real projects)

├── src/
│ └── myproject/ # Main application package
│ ├── init.py

│ ├── api/ # API layer (Flask/FastAPI routers/controllers)
│ │ ├── init.py
│ │ ├── routes.py
│ │ └── middlewares.py

│ ├── core/ # Core utilities (config, logging, constants)
│ │ ├── init.py
│ │ ├── config.py
│ │ └── logger.py

│ ├── services/ # Business logic classes & service layers
│ │ ├── init.py
│ │ ├── translation_service.py
│ │ └── transcription_service.py

│ ├── models/ # Data models (Pydantic, schemas, DTOs)
│ │ ├── init.py
│ │ └── request_models.py

│ ├── data/ # Data assets used internally (optional)
│ │ ├── inputs/
│ │ └── outputs/
│ │
│ └── app.py # API entrypoint (e.g., Flask app or FastAPI app)

├── tests/
│ ├── init.py
│ ├── test_api.py
│ ├── test_translation_service.py
│ └── test_transcription_service.py

└── workflows/
└── ci.yml

Logical Layering (for clarity and testability)

Your project is structured in layers:

  1. API Layer (api/)
  • Contains only routing, request parsing, and HTTP-related logic.
  1. Service Layer (services/)
  • Business logic — these should be fully testable without running the API.
  1. Models Layer (models/)
  • Schema validation (Pydantic), request/response structures.
  1. Core Layer (core/)
  • Configuration, logging, environment handling.
  1. Data Layer (data/)
  • Local files your script may need (audio, models, temp outputs).
  1. App Entrypoint (app.py)
  • Creates and starts the API (similar to main()).

Metadata

Metadata

Assignees

Labels

documentationImprovements or additions to documentationhelp wantedExtra attention is neededquestionFurther information is requested

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions