Files
mt-drugs/README.md
2026-01-16 12:48:03 -05:00

114 lines
2.9 KiB
Markdown

# Drug Inventory System
A simple, lightweight drug inventory management system for small charity veterinary clinics.
## Tech Stack
- **Backend**: Python + FastAPI + Uvicorn + SQLite
- **Frontend**: Plain HTML, CSS, JavaScript (no frameworks)
- **Database**: SQLite (file-based, zero setup)
## Features
✅ Add, edit, delete drugs
✅ Track quantities and units
✅ Low stock alerts
✅ Filter by inventory status
✅ Responsive design (works on desktop and mobile)
✅ Fast and lightweight
## Quick Start (Docker - Recommended)
Everything runs in containers. Just make sure you have Docker and Docker Compose installed.
```bash
docker-compose up
```
That's it! Everything will start automatically:
- **Frontend**: `http://localhost` (Nginx serving the UI)
- **Backend API**: `http://localhost:8000` (FastAPI)
- **API Docs**: `http://localhost:8000/docs` (Interactive Swagger UI)
- **Database**: SQLite file at `./drugs.db` (auto-created)
To stop:
```bash
docker-compose down
```
To rebuild after code changes:
```bash
docker-compose up --build
```
## Project Structure
```
/drugs
/backend
/app
__init__.py # Database config
database.py # Database connection setup
models.py # SQLAlchemy models
main.py # FastAPI app and routes
requirements.txt # Python dependencies
Dockerfile # Container image
/frontend
index.html # Main page
styles.css # All styling
app.js # All JavaScript logic
docker-compose.yml # Run everything with Docker Compose
nginx.conf # Nginx config for frontend
```
## API Endpoints
| Method | Endpoint | Description |
|--------|----------|-------------|
| GET | `/drugs` | List all drugs |
| GET | `/drugs/{id}` | Get specific drug |
| POST | `/drugs` | Create new drug |
| PUT | `/drugs/{id}` | Update drug |
| DELETE | `/drugs/{id}` | Delete drug |
| GET | `/drugs/low-stock` | Get low stock drugs |
## Database
SQLite database is stored as `drugs.db` in the project root. It's a single file that persists between container restarts. You can:
- Backup by copying the file
- Share with team members
## Configuration
Edit environment variables in `docker-compose.yml`:
```yaml
environment:
- DATABASE_URL=sqlite:///./drugs.db
```
## Development
When you run `docker-compose up`, the backend automatically reloads when code changes (`--reload` flag). Just refresh your browser to see updates.
## Production Deployment
For production:
1. Disable `--reload` in docker-compose.yml command
2. Use a production WSGI server (e.g., Gunicorn)
3. Add environment variables for security
4. Use a managed database instead of SQLite if scaling
## Future Enhancements
- User authentication & roles
- Audit log (who changed what and when)
- Export to CSV
- Barcode/QR code scanning
- Email alerts for low stock
- Multi-location support
- Mobile app