A FastAPI backend practice project for the linda xdr project, featuring log processing, anomaly detection, and incident response.
- Docker & Docker Compose
- Poetry (for local development)
-
Environment Setup Copy the example environment file and fill in your secrets:
cp .env.example .env
-
Build the Docker Images
docker-compose build
-
Run Database Migrations This applies any pending database schema changes.
docker-compose run --rm migrate
-
Start the Application
docker-compose up backend
The API will be available at http://localhost:8000.
- Swagger UI:
http://localhost:8000/docs - ReDoc:
http://localhost:8000/redoc
When you change a SQLAlchemy model in src/models/, you must create a new migration.
-
Make sure the database container is running:
docker-compose up -d db
-
Run the migration creation script from your host machine:
./create-migration.sh "Your descriptive migration message"Note: You might need to make it executable first:
chmod +x create-migration.sh -
Apply the new migration:
docker-compose run --rm migrate
teapec-backend/ ├── alembic/ # Database migrations ├── scripts/ # Startup and utility scripts ├── src/ # Main application source code │ ├── api/ # API endpoints (routers) │ ├── core/ # Core config, DB, security │ ├── models/ # SQLAlchemy models │ ├── schemas/ # Pydantic schemas │ └── services/ # Business logic ├── .env.example # Environment variables template ├── docker-compose.yml # Docker Compose configuration ├── Dockerfile # Instructions for building the Docker image └── pyproject.toml # Python dependencies (Poetry)