No description
- Python 99.6%
- Dockerfile 0.4%
| app | ||
| tests | ||
| .dockerignore | ||
| .env.example | ||
| .gitignore | ||
| .woodpecker.yml | ||
| AGENTS.md | ||
| database.sql | ||
| docker-compose.production.yml | ||
| docker-compose.test.yml | ||
| Dockerfile | ||
| openapi.yml | ||
| README.md | ||
| requirements.txt | ||
RDTS API
Secure Python REST API scaffold built with FastAPI using layered architecture:
- controllers: API route handlers
- services: business logic
- repository: database access
The project includes:
- environment profiles for local, test, production
- OpenAPI YAML documentation for every implemented endpoint
- integration tests for every implemented endpoint
- Docker setup for deployable test/production stacks
Tech Stack
- FastAPI
- SQLAlchemy
- PostgreSQL (containerized for compose test/production)
- PyTest + FastAPI TestClient
Project Structure
- app/main.py
- app/controllers/
- app/services/
- app/repository/
- app/db/
- app/core/
- app/schemas/
- tests/integration/
- openapi.yml
Environment Files
- .env.local
- .env.test
- .env.production
- .env.example
Important:
- Update API_KEY in every environment before deployment.
- Update production DATABASE_URL and ALLOWED_HOSTS/ALLOWED_ORIGINS with real values.
Run Locally
- Create and activate a virtual environment.
- Install dependencies:
pip install -r requirements.txt
- Start API with local env:
uvicorn app.main:app --host 0.0.0.0 --port 8000
- Try endpoints:
curl http://localhost:8000/
curl -H "X-API-Key: local-dev-api-key-please-change-123456" http://localhost:8000/api/v1/health
Run Tests
Use the required command:
python -m pytest
Docker Deployment
Test stack
docker compose -f docker-compose.test.yml up --build
Production stack
docker compose -f docker-compose.production.yml up --build -d
API Security Baseline
- API key authentication on protected endpoint(s)
- Trusted host validation
- CORS allow-list
- Security response headers
- Request size limit middleware
- Parameterized SQL query for DB health check
OpenAPI YAML
See openapi.yml for the endpoint contract.