This document outlines the new microservices-based architecture for the PharmaSight™ platform.
The platform has been refactored from a monolithic Flask application into a distributed system of specialized microservices, orchestrated with Docker Compose. This modern architecture provides enhanced scalability, maintainability, and performance. An API Gateway acts as the single entry point for all client requests, routing them to the appropriate backend service.
The architecture consists of the following services:
| Service | Port | Description |
|---|---|---|
| API Gateway | 8080 | The single entry point for all client requests. Routes traffic to the appropriate downstream service. |
| Authentication | 8005 | Manages user authentication (JWT), authorization, and role-based access control (RBAC). |
| Compound Analysis | 8001 | Handles molecular analysis, property calculation (RDKit), and chemical structure visualization. |
| Analog Generation | 8002 | Generates and analyzes chemical analogs, including similarity scoring and patent analysis. |
| ML Models | 8003 | Serves pre-trained machine learning models for predicting ADMET properties, toxicity, and more. |
| Quantum Calculator | 8004 | Performs high-precision quantum chemistry calculations (DFT) using PySCF for advanced property prediction. |
| PostgreSQL Database | 5432 | Primary relational database for storing compound information, user data, and research findings. |
| Redis Cache | 6379 | In-memory data store for caching expensive calculations and managing session data. |
- Docker (version 20.10+)
- Docker Compose (version 1.29+)
- Python 3.11+ (for running tests)
-
Clone the Repository:
git clone https://github.com/justincihi/pharmasight-platform.git cd pharmasight-platform -
Configure Environment (Optional):
cp .env.example .env # Edit .env with your preferred settings -
Build and Start Services: From the root of the project directory, run:
docker-compose up --build -d
Or use the Makefile:
make up
-
Verify Services Are Running: Check the health of all services:
curl http://localhost:8080/health
Or use:
make health
-
Run Integration Tests:
python3 test_microservices.py
Or use:
make test
Once all services are running:
- API Gateway: http://localhost:8080
- Interactive API Docs: http://localhost:8080/docs
- Health Check: http://localhost:8080/health
View Logs:
docker-compose logs -f # All services
docker-compose logs -f compound-service # Specific service
make logs # Using Makefile
make logs-compound # Specific serviceStop Services:
docker-compose down
make downRestart Services:
docker-compose restart
make restartClean Everything:
docker-compose down -v
make cleanAll endpoints are accessed through the API Gateway. The gateway uses the path to route to the correct service.
Example: A POST request to http://localhost:8080/compound-analysis/analyze will be routed to the /analyze endpoint on the compound-service.
-
Authentication:
POST /auth-service/token: Obtain a JWT access token.GET /auth-service/users/me: Get information about the currently authenticated user.
-
Compound Analysis:
POST /compound-analysis/analyze: Analyze a compound by name or SMILES string.
-
Analog Generation:
POST /analog-generation/generate: Generate analogs for a parent compound.
-
ML Predictions:
POST /ml-models/predict/admet: Predict ADMET properties for a list of molecules.POST /ml-models/predict/properties: Predict other properties for a single molecule.
-
Quantum Calculations:
POST /quantum-calculator/calculate: Perform a DFT calculation on a molecule.
When developing a specific service, you can run just that service and its dependencies. For example, to work on the compound-service:
docker-compose up -d db redis compound-serviceThis will start the database, cache, and the compound service, allowing you to test it in isolation. Remember to rebuild the image if you make changes to the code:
docker-compose up -d --build compound-service
# Or using Makefile
make rebuild-compound- Make code changes in
services/[service-name]/ - Rebuild the service:
make rebuild-[service-name] - Check logs:
make logs-[service-name] - Test changes: Run integration tests or use curl
- Comprehensive API Documentation: See API_DOCUMENTATION.md
- Deployment Guide: See MICROSERVICES_DEPLOYMENT.md
- Environment Configuration: See .env.example
See the MICROSERVICES_DEPLOYMENT.md file for detailed troubleshooting steps.
Common issues:
- Port conflicts: Change ports in docker-compose.yml
- Services won't start: Check logs with
make logs - Database connection errors: Verify DATABASE_URL environment variable
- Health check failures: Ensure curl is installed in containers