A hybrid Go-Python application that populates PostgreSQL with test data and provides Excel export functionality via FastAPI.
- FastAPI Backend: REST API endpoints for triggering data operations
- Go Binary: High-performance Excel generation and S3 upload
- PostgreSQL: Database for storing test data
- LocalStack: Local S3-compatible storage
- Docker: Containerization for all components
- Docker and Docker Compose
- Git
- Clone the repository:
git clone https://github.com/utksngh/postgres-data-populator.git
cd postgres-data-populator- Start the services:
docker-compose up --buildThis will:
- Start PostgreSQL database
- Initialize LocalStack (S3)
- Build and run the FastAPI service
- Populate the database with test data
- Start the API server
GET /download-xlsx/Generates an Excel file from PostgreSQL data and returns a presigned S3 URL.
- PostgreSQL 15
- Contains 1 million rows of test data
- Auto-populated on startup
- REST API endpoints
- Executes Go binary for Excel operations
- Handles S3 presigned URLs
- High-performance Excel file generation
- Concurrent data processing
- Direct S3 upload capability
- S3-compatible local storage
- Available at
http://localhost:4566
docker exec -it postgres_db psql -U user -d test_db# Check database row count
SELECT COUNT(*) FROM test_table;
# Check S3 buckets
aws --endpoint-url=http://localhost:4566 s3 ls
# View logs
docker-compose logs -f backendDB_HOST: Database hostnameDB_PORT: Database port (default: 5432)DB_NAME: Database nameDB_USER: Database usernameDB_PASSWORD: Database password
AWS_ENDPOINT_URL: LocalStack endpointAWS_ACCESS_KEY_ID: AWS access keyAWS_SECRET_ACCESS_KEY: AWS secret key
.
├── backend/
│ ├── main.go # Go Excel generator
│ ├── populate_data.py # Database population script
│ ├── main.py # FastAPI application
│ ├── requirements.txt # Python dependencies
│ ├── Dockerfile # Multi-stage build
│ └── entrypoint.sh # Startup script
├── docker-compose.yml
├── init.sql
└── README.md
- Concurrent Excel generation
- Batch processing of database rows
- Streaming Excel writer to minimize memory usage
- Optimized database queries
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request