A full-stack distributed application that calculates Fibonacci numbers using a microservices architecture with Docker containerization and automated CI/CD deployment to Azure Container Instances.
This application allows users to:
- Submit Fibonacci Index: Users enter a number (index) between 0-40 to calculate the corresponding Fibonacci number
- Real-time Calculation: The system processes the request asynchronously using a worker pattern
- View Results: Users can see:
- All previously submitted indices (stored in PostgreSQL)
- Calculated Fibonacci values (stored in Redis)
- Automatic Updates: The UI polls for new results every 2 seconds and refreshes the list of indices every 5 seconds
- User submits an index through the React frontend
- Server receives the request and:
- Stores the index in PostgreSQL (permanent storage)
- Places a placeholder value in Redis (
"Nothing yet!") - Publishes the index to a Redis channel (
insert)
- Worker process:
- Subscribes to the Redis
insertchannel - Receives the index and calculates the Fibonacci number
- Updates Redis with the calculated value
- Subscribes to the Redis
- Frontend polls Redis and displays the result when ready
- Server: Handles HTTP requests, data validation, and user interactions
- Worker: Handles CPU-intensive calculations without blocking the server
- The server can handle multiple requests simultaneously
- Workers can be scaled independently based on calculation load (using Kubernetes)
- Multiple worker instances can process calculations in parallel
- Non-blocking: Server responds immediately to users without waiting for calculations
- Asynchronous Processing: Calculations happen in the background
- Better Resource Utilization: CPU-intensive tasks don't block I/O operations
- If a worker crashes, the server continues to accept requests
- Failed calculations can be retried by other workers
- Server remains responsive even during heavy computational loads
- Docker and Docker Compose installed
- Node.js 20+ (for local development without Docker)
# Start all services
docker-compose -f docker-compose-dev.yml up
# Or in detached mode
docker-compose -f docker-compose-dev.yml up -d
# View logs
docker-compose -f docker-compose-dev.yml logs -f
# Stop all services
docker-compose -f docker-compose-dev.yml down- Frontend: http://localhost:3050
- API: http://localhost:3050/api
- PostgreSQL: localhost:5432
- Redis: localhost:6379
REDIS_HOST: Redis server hostnameREDIS_PORT: Redis server port (default: 6379)PGUSER: PostgreSQL usernamePGHOST: PostgreSQL hostnamePGDATABASE: PostgreSQL database namePGPASSWORD: PostgreSQL passwordPGPORT: PostgreSQL port (default: 5432)PORT: Server port (default: 5000)
REDIS_HOST: Redis server hostnameREDIS_PORT: Redis server port (default: 6379)
- Frontend: React 19, TypeScript, Vite, TailwindCSS, TanStack Query
- Backend: Express.js, TypeScript, Node.js
- Worker: TypeScript, Node.js, ioredis
- Database: PostgreSQL 16
- Cache/Message Broker: Redis 7
- Reverse Proxy: Nginx 1.27
- Containerization: Docker
This is a learning project. Feel free to fork and experiment!
Note: This application is designed for educational purposes to demonstrate microservices architecture, Docker containerization, and cloud deployment patterns.