A FastAPI backend application for motor management system with PostgreSQL 17 database.
- FastAPI framework with async support
- PostgreSQL 17 database with async SQLAlchemy
- Alembic for database migrations
- Docker and Docker Compose setup
- Health check endpoints
- CORS middleware support
- Clone the repository and navigate to the project directory
- Run the application using Docker Compose:
docker-compose up -dThis will start:
- PostgreSQL 17 database on port 5432
- FastAPI application on port 8000
- Install dependencies:
pip install -r requirements.txt- Set up environment variables:
cp .env.example .env
# Edit .env with your configuration- Run database migrations:
alembic upgrade head- Start the application:
uvicorn app.main:app --host 0.0.0.0 --port 8000Once the application is running, you can access:
- Interactive API docs: http://localhost:8000/docs
- ReDoc documentation: http://localhost:8000/redoc
The application uses PostgreSQL 17 with the following default configuration:
- Host: localhost (or
dbin Docker) - Port: 5432
- Database: motor_backend
- Username: postgres
- Password: postgres
app/
├── api/
│ └── v1/
│ └── endpoints/ # API endpoints
├── core/
│ ├── config.py # Configuration settings
│ └── database.py # Database connection
├── crud/ # Database operations
├── models/ # SQLAlchemy models
├── schemas/ # Pydantic schemas
└── services/ # Business logic
- Create a new router in
app/api/v1/endpoints/ - Import and include the router in
app/main.py
- Create a new migration:
alembic revision --autogenerate -m "Description of changes"- Apply migrations:
alembic upgrade head- Start services:
docker-compose up -d - Stop services:
docker-compose down - View logs:
docker-compose logs -f - Rebuild:
docker-compose up --build