A full-stack web application for predicting and monitoring Antimicrobial Resistance (AMR) patterns using Deep Learning. It provides a comprehensive interface for AMR predictions, electronic prescription generation and interactive regional surveillance; built with React (Vite), FastAPI, and MongoDB.
FYP_Project/
├── client/ # React frontend (Vite)
│ ├── src/
│ │ ├── pages/ # Page components
│ │ │ ├── Home.jsx # Landing page
│ │ │ ├── Prediction.jsx # AMR Prediction page
│ │ │ ├── Surveillance.jsx # Surveillance dashboard
│ │ │ └── EPrescription.jsx # E-Prescription module
│ │ ├── components/ # Reusable components
│ │ │ ├── AntibioticSuggestionList.jsx
│ │ │ ├── Button.jsx
│ │ │ ├── Card.jsx
│ │ │ ├── FileDrop.jsx
│ │ │ ├── Footer.jsx
│ │ │ ├── Header.jsx
│ │ │ ├── IconButton.jsx
│ │ │ ├── Input.jsx
│ │ │ ├── OrganismDistributionChart.jsx
│ │ │ ├── PakistanMap.jsx
│ │ │ ├── PrescriptionForm.jsx
│ │ │ ├── PrescriptionSummary.jsx
│ │ │ ├── RegionDetailsPanel.jsx
│ │ │ └── ResistanceTrendsChart.jsx
│ │ ├── theme/ # Theme configuration
│ │ │ └── ThemeProvider.jsx
│ │ ├── App.jsx # Main app component with routing
│ │ ├── main.jsx # Entry point
│ │ └── index.css # Global styles
│ ├── package.json
│ ├── vite.config.js
│ ├── tailwind.config.js
│ ├── Dockerfile
│ ├── Dockerfile.dev
│ └── nginx.conf
├── server/ # FastAPI backend
│ ├── main.py # FastAPI application & API routes
│ ├── requirements.txt # Python dependencies
│ ├── Dockerfile
│ └── models/ # ML models directory
├── docker-compose.yml # Docker orchestration
├── env.example # Environment variables template
└── README.md
- Docker and Docker Compose installed
- (Optional) Node.js 18+ and Python 3.10+ for local development
-
Clone and navigate to the project:
cd FYP_Project -
Set up environment variables:
cp env.example .env
Edit
.envand update the values as needed (especiallySECRET_KEYfor production). -
Build and start all services:
docker-compose up --build
-
Access the application:
- Frontend: http://localhost:5173
- Backend API: http://localhost:8000
- API Docs: http://localhost:8000/docs
- MongoDB: localhost:27017
-
Navigate to client directory:
cd client -
Install dependencies:
npm install
-
Start development server:
npm run dev
Frontend will be available at http://localhost:5173
-
Navigate to server directory:
cd server -
Create virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Set environment variables: Create a
.envfile in theserver/directory:MONGODB_URI=mongodb://localhost:27017/ DB_NAME=amr_db MODEL_PATH=./models SECRET_KEY=your-secret-key
-
Start the server:
uvicorn main:app --reload --host 0.0.0.0 --port 8000
Backend will be available at http://localhost:8000
Run MongoDB locally or use Docker:
docker run -d -p 27017:27017 --name mongodb mongo:7.0curl http://localhost:8000/healthExpected response:
{
"status": "healthy",
"message": "Backend is running",
"database": "connected"
}Open http://localhost:5173 in your browser. The status card should show "Backend is healthy" if the connection is successful.
GET /health- Check backend and database status
GET /api/predictions- Get all predictionsPOST /api/predictions- Create a new prediction
GET /api/surveillance- Get surveillance dataGET /api/surveillance/regions- Get regional surveillance data with geographic coordinatesGET /api/surveillance/trends- Get resistance trends over time (12 months)GET /api/surveillance/organisms- Get organism distribution data (4 species)
- Interactive docs: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
Copy env.example to .env and configure:
MONGODB_URI: MongoDB connection string (default:mongodb://mongodb:27017/)DB_NAME: Database name (default:amr_db)MODEL_PATH: Path to ML model files (default:/app/models)SECRET_KEY: Secret key for security (change in production!)VITE_API_URL: Frontend API URL (default:http://localhost:8000)
# Start all services
docker-compose up
# Start in detached mode
docker-compose up -d
# Rebuild and start
docker-compose up --build
# Stop all services
docker-compose down
# Stop and remove volumes
docker-compose down -v
# View logs
docker-compose logs -f
# View logs for specific service
docker-compose logs -f server- Client: React app served via Nginx on port 5173
- Server: FastAPI backend on port 8000
- MongoDB: Database on port 27017
- Frontend: Add components in
client/src/ - Backend: Add routes in
server/main.pyor create separate router modules - Database: Collections are created automatically on first use
- AMR Prediction: Upload mass spectrometry data, enter clinical information, and get resistance predictions
- E-Prescription Module: Generate electronic prescriptions based on prediction results with:
- Antibiotic recommendations (sorted by safety, usage, first-line preference)
- Resistant antibiotic warnings
- Prescription form with dosage, duration, and instructions
- Print-ready prescription summary (single page PDF)
- Surveillance Dashboard:
- Interactive Pakistan map with regional resistance markers
- Resistance trends over time (line charts)
- Organism distribution charts (bar charts)
- Regional data tables and details panels
- Responsive Design: Mobile-friendly UI with Tailwind CSS
- Theme System: Consistent design system with customizable colors
- RESTful API with FastAPI
- MongoDB integration for data persistence
- Health check endpoints
- CORS configuration for frontend communication
- Mock data endpoints for development/testing
- The app includes CORS middleware configured for local development
- MongoDB connection is optional - the app will run without it but with limited functionality
- All services are connected via Docker network
amr_network - Health checks are configured for MongoDB and server services
- E-Prescription print layout is optimized for single-page A4 printing
- The surveillance dashboard uses Leaflet maps and Recharts for data visualization