How jonathanarroyavegonzalez/backend-marketplace works
Project Type and Purpose
• This is a backend-only application: a RESTful Marketplace API for local entrepreneurs.
• It uses Python + FastAPI, organized according to the Clean Architecture (API, Application, Domain, Infrastructure).
File Structure and Layers
• API Layer
• main.py – FastAPI app entrypoint
• controllers/… – HTTP handlers (authController, postController, etc.)
• Application Layer (dddpy/application)
• Models – DTOs and input models (loginDataModel.py, postModel.py, etc.)
• ResponseModels – response DTOs (postDetailResponseModel.py)
• Services – business use-case implementations (authService.py, postService.py…)
• Shared – common abstractions (ResponseModel)
• abstract – interface definitions (abstractStorage.py)
• Domain Layer (dddpy/domain)
• Enums – domain value sets (orderStatus, postStatus…)
• schemas – internal data representations (order_dto.py, user_dto.py…)
• repository.py – domain interface for data access
• Infrastructure Layer (dddpy/insfrastructure)
• Auth – JWT dependency & manager (jwt_depends.py, jwt_manage.py)
• services – low-level helpers (encryptService.py, storageService.py)
• sqlite – SQLAlchemy database & concrete repository implementation
• Configuration & Resources
• environment/env.py – environment variables
• resources/images + requirements.txt
• Tests – validate controllers and services
README Insights
• Confirms Clean Architecture and the four layers.
• Lists key technologies: FastAPI, SQLAlchemy, Python.
Main Components
a. Clients (Web/Mobile UI or Postman)
b. API Layer (FastAPI app + Controllers)
c. Application Layer (Use-Case Services + Models)
d. Domain Layer (Entities, Enums, Repository Interfaces)
e. Infrastructure Layer
• Auth (JWT)
• Persistence (SQLite via SQLAlchemy + Repository)
• Auxiliary services (Encryption, File Storage)
f. Database (marketplace.db)
g. Environment/Config
Relationships and Data Flow
• Clients → HTTP Request → FastAPI Router (controllers)
• Controllers → call Application Services
• Services → validate/use Models and call Repository Interfaces
• Repository Interfaces (Domain) → implemented by Infrastructure Repository → SQLAlchemy → Database
• Services use Infrastructure Auth/Encrypt/Storage as needed → return ResponseModels → Controllers → HTTP Response → Clients
Architectural Patterns
• Clean Architecture (layered, inward dependencies)
• Dependency Inversion: Application depends on Domain abstractions, not implementations
• Separation of Concerns: Controllers vs. Business Logic vs. Data Access vs. Domain Entities