This project implements a FastAPI application using the Hexagonal Architecture (Ports and Adapters) pattern.
project/
├── constants/ # Constants, enums, schema definitions
├── domains/ # Business domains
│ └── domain_name/ # Specific domain
│ ├── application/ # Incoming ports/adapters (controllers)
│ ├── core/ # Domain logic & outgoing ports (interfaces)
│ │ ├── model/ # Domain models and entities
│ │ └── port/ # Interface definitions
│ │ ├── incoming/ # Incoming ports (use cases/services)
│ │ └── outgoing/ # Outgoing ports (repositories/clients)
│ ├── domain_infrastructure/ # Outgoing adapters (implementations)
│ └── deployment/ # Deployment configuration
│ └── router.py # Domain API routes
├── infrastructure/ # Technical adapters (DB, external APIs)
├── utils/ # Shared utilities (logging, error handling)
│ ├── common_utils.py # Common utility functions
│ ├── exception.py # Exception handling classes
│ ├── logger.py # Logging configuration
│ └── response.py # API response formatter
├── .gitignore # Git ignore file
├── api_server.py # FastAPI server with health check
└── requirements.txt # Project dependencies
- Python 3.10 or higher
- pip
- Clone the repository:
git clone https://github.com/yourusername/hexagonal-api.git
cd hexagonal-api- Create a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies:
pip install -r requirements.txtpython api_server.pyThe API will be available at http://localhost:8080
GET /health- Health check endpointGET /readiness- Readiness check endpointGET /api/health- Health domain endpoint