A comprehensive medication management system built with .NET Aspire that enables users to track medications, schedules, dosing logs, and potential drug interactions.
MedicineTrack follows a microservices architecture built on .NET Aspire, providing a scalable and cloud-native solution for medication management.
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β API Gateway (Port 5000) β
β Route: /medicines/* /configs/* β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββββ΄ββββββββββββββββ
β β
βββββββββββββββββββββββββββββββββββ βββββββββββββββββββββββββββββββββββ
β MedicineTrack.Api β β MedicineTrack.Configuration β
β (Port 5001) β β (Port 5002) β
β β β β
β β’ Medication Management β β β’ Organization Management β
β β’ Medication Logging β β β’ User Management β
β β’ Drug Interaction Checking β β β’ System Configuration β
β β’ Medication Database Lookup β β β
βββββββββββββββββββββββββββββββββββ βββββββββββββββββββββββββββββββββββ
β β
βββββββββββββββββ¬ββββββββββββββββ
β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Infrastructure β
β β
β β’ PostgreSQL (Medication & Configuration DBs) β
β β’ Redis/Valkey (Caching) β
β β’ Entity Framework Core (Data Access) β
β β’ Migrations (Database Schema Management) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
medicine_track/
βββ src/
β βββ MedicineTrack.AppHost/ # .NET Aspire App Host
β βββ MedicineTrack.Api/ # Main API service
β βββ MedicineTrack.Configuration/ # Configuration service
β βββ MedicineTrack.Gateway/ # API Gateway (YARP)
β βββ MedicineTrack.Medication.Data/ # Medication domain models
β βββ MedicineTrack.Configuration.Data/ # Configuration domain models
β βββ MedicineTrack.Medication.Migrations/ # Database migrations
β βββ MedicineTrack.Configuration.Migrations/ # Database migrations
β βββ MedicineTrack.Tests/ # Unit tests
β βββ MedicineTrack.End2EndTests/ # End-to-end tests
βββ deploy-aspire.sh # Kubernetes deployment script
βββ README.md
- Medication Management: Create, read, update, and delete medications with detailed information
- Flexible Scheduling: Support for complex medication regimens with multiple frequency types
- Medication Logging: Track when medications are taken, skipped, or taken as needed
- Drug Interaction Checking: Identify potential dangerous medication combinations
- Medication Database: Search and lookup medications with NDC codes and detailed information
- User Management: Multi-tenant system with organization and user management
- Health Monitoring: Built-in health checks and observability
Supports various frequency types:
- Daily: Once or multiple times per day
- Weekly: Specific days of the week
- Monthly: Specific days of the month
- As Needed: PRN medications
- Custom Intervals: Every X days, weeks, or months
- Basic information (name, generic name, brand name, strength, form)
- Physical properties (shape, color)
- Lifecycle management (start date, end date, archival)
- Multiple independent schedules
- Flexible frequency patterns
- Multiple daily dosing times
- Quantity and unit tracking
- Day-of-week specifications
- Timestamp tracking (taken vs. logged)
- Status tracking (taken, skipped, as-needed)
- Actual quantity taken
- Schedule association
- Notes and additional context
- Framework: .NET 9.0 with ASP.NET Core Minimal APIs
- Orchestration: .NET Aspire
- Database: PostgreSQL with Entity Framework Core
- Caching: Redis/Valkey
- API Gateway: YARP (Yet Another Reverse Proxy)
- Documentation: OpenAPI/Swagger
- Testing: xUnit, End-to-end testing framework
- Deployment: Kubernetes with Aspire integration
- .NET 9.0 SDK
- Docker Desktop
- Kubernetes cluster (for production deployment)
- PostgreSQL (or use Docker container)
- Redis (or use Docker container)
-
Clone the repository
git clone <repository-url> cd medicine_track
-
Install .NET Aspire workload
dotnet workload install aspire
-
Run the application
cd src dotnet run --project MedicineTrack.AppHost -
Access the services
- Aspire Dashboard:
http://localhost:15888 - API Gateway:
http://localhost:5000 - Medicine API:
http://localhost:5001 - Configuration API:
http://localhost:5002
- Aspire Dashboard:
Once running, access the OpenAPI documentation:
- Gateway API:
http://localhost:5000/openapi - Medicine API:
http://localhost:5001/openapi - Configuration API:
http://localhost:5002/openapi
POST /- Create new medicationGET /- List user medications (with filtering)GET /{medicationId}- Get specific medicationPUT /{medicationId}- Update medicationDELETE /{medicationId}- Archive medication
POST /medications/{medicationId}/logs- Log medication doseGET /medication-logs- Get all user logsGET /medications/{medicationId}/logs- Get logs for specific medicationPUT /medication-logs/{logId}- Update log entryDELETE /medication-logs/{logId}- Delete log entry
GET /search- Search medication database
POST /check- Check for drug interactions
POST /- Create organizationGET /- List organizationsGET /{organizationId}- Get specific organizationPUT /{organizationId}- Update organizationDELETE /{organizationId}- Delete organization
POST /- Create userGET /- List usersGET /{userId}- Get specific userPUT /{userId}- Update userDELETE /{userId}- Delete user
cd src
dotnet test MedicineTrack.Testscd src
dotnet test MedicineTrack.End2EndTestsUse the provided .http files in VS Code with the REST Client extension:
src/MedicineTrack.Api/Medicines.httpsrc/MedicineTrack.Api/Health.httpsrc/MedicineTrack.Configuration/MedicineTrack.Configuration.httpsrc/MedicineTrack.Gateway/MedicineTrack.Gateway.http
Use the provided deployment script:
./deploy-aspire.shThis script will:
- Check prerequisites (kubectl, Docker, .NET SDK)
- Create Kubernetes namespace
- Build the application
- Generate Aspire manifest
- Convert to Kubernetes manifests using aspirate
- Deploy to local cluster
- Set up port forwarding
-
Build the application
cd src dotnet build -
Generate Aspire manifest
dotnet run --project MedicineTrack.AppHost --publisher manifest --output-path ../infra/aspire-manifest.json
-
Install aspirate tool
dotnet tool install -g aspirate
-
Generate Kubernetes manifests
cd infra aspirate generate \ --input-path aspire-manifest.json \ --output-path k8s-manifests \ --namespace medicine-track \ --container-registry docker.io \ --container-image-tag latest -
Apply to Kubernetes
kubectl apply -f k8s-manifests -n medicine-track
Configure the following environment variables for production:
ASPNETCORE_ENVIRONMENT=ProductionConnectionStrings__DefaultConnection=<PostgreSQL connection string>ConnectionStrings__Redis=<Redis connection string>
The application uses Entity Framework Core with PostgreSQL. Database migrations are handled by dedicated migration projects:
MedicineTrack.Medication.MigrationsMedicineTrack.Configuration.Migrations
Redis/Valkey is used for caching. Configuration is handled through .NET Aspire's service discovery.
The API Gateway uses YARP for reverse proxy functionality. Routes are configured in appsettings.json:
/medicines/*β Medicine API/configs/*β Configuration API
- Gateway:
GET /health - Medicine API:
GET /health - Configuration API:
GET /health
The Aspire dashboard provides comprehensive monitoring:
- Service health and metrics
- Distributed tracing
- Log aggregation
- Resource utilization
Access at: http://localhost:15888 (development) or via port forwarding (Kubernetes)
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow C# coding conventions
- Use nullable reference types
- Write unit tests for new features
- Update API documentation
- Ensure all tests pass before submitting
This project is licensed under the MIT License - see the LICENSE file for details.
For questions and support:
- Create an issue in the GitHub repository
- Check the API documentation for endpoint details
- Review the test files for usage examples
- Authentication and authorization
- Real-time notifications
- Mobile app integration
- Advanced analytics and reporting
- Integration with pharmacy systems
- Machine learning for adherence predictions
- Multi-language support
- Offline capability
Built with β€οΈ using .NET Aspire and modern cloud-native technologies.