This repository contains the backend code for the ElectOMate project. The backend is built using Python and provides various functionalities related to election data management and processing.
All development for ElectOMate-Backend happens through Docker Compose, which provides a consistent environment and handles all dependencies automatically.
- Docker and Docker Compose installed
-
Clone the repository:
git clone https://github.com/ElectOMate/ElectOMate-Backend.git cd ElectOMate-Backend -
Setup environment variables:
cp .env.example .env # Edit .env with your API keys (Weaviate, OpenAI) -
Start the development stack:
make dev # or: docker-compose up --build -
Access the application:
- API: http://localhost:8000
- Database: localhost:5433 (from host)
- API Docs: http://localhost:8000/docs
- View logs:
make dev-logs - Access container shell:
make dev-shell - Create migrations:
make migration message="your change" - Run migrations:
make db-migrate - Stop services:
make down
Production deployments use external PostgreSQL databases only (no containerized database). Supports managed databases like AWS RDS, Azure Database, Google Cloud SQL, etc.
-
Configure environment variables:
cp .env.example .env # Edit .env with your database configuration -
Required environment variables for production:
POSTGRES_HOST=your-database-host.amazonaws.com POSTGRES_PORT=5432 POSTGRES_DB=em_prod POSTGRES_USER=postgres POSTGRES_PASSWORD=your-secure-password
make prod # or: docker compose -f docker-compose.prod.yml up --build -d
-
Build the container:
docker build -t em/backend . -
Run with external database:
docker run --env-file ./.env -p 8000:8000 em/backend
All commands are available via Makefile for easy development:
make dev- Start full development stackmake dev-logs- View application logsmake dev-shell- Access development container shellmake down- Stop all services
make db-migrate- Run database migrationsmake migration message="description"- Create new migration
make prod- Start production stackmake clean- Clean up containers and volumes
The development setup includes:
- ✅ Source code hot reload
- ✅ Automatic database migrations on startup
- ✅ Development database with proper extensions
- ✅ Comprehensive logging and debugging
# Connect to development database
docker-compose exec postgres psql -U postgres -d em_dev
# Or from host (when postgres port is exposed)
psql -h localhost -p 5433 -U postgres -d em_devThe application requires these environment variables:
WV_URL- Weaviate vector database URLWV_API_KEY- Weaviate API keyOPENAI_API_KEY- OpenAI API key for LLM servicesENV- Environment (dev/production)POSTGRES_URL- Database connection string (auto-configured in Docker)
The backend provides:
- FastAPI REST API with automatic OpenAPI documentation
- PostgreSQL database with Alembic migrations
- Vector search via Weaviate integration
- LLM integration with OpenAI for intelligent responses
- Document processing with automatic chunking and embedding
- Real-time capabilities with WebSocket support
- Fork the repository
- Create a feature branch
- Use
make devfor development - Run tests and ensure migrations work
- Submit a pull request
For detailed development setup, see the Docker Development section above.