Cliniva Backend is a comprehensive, enterprise-grade clinic management system API built with NestJS and TypeScript. It provides a robust foundation for managing multi-tenant healthcare operations, from individual clinics to large healthcare organizations.
- Flexible Subscription Plans: Company, Complex, and Clinic-level subscriptions
- Hierarchical Organization: Organization → Complexes → Departments → Clinics
- Unified Access Control: Role-based permissions across all organizational levels
- Patient Management: Comprehensive patient records with medical history
- Appointment Scheduling: Advanced booking system with service integration
- Medical Reports: Digital medical records with audit trails
- Doctor Specialties: Multi-specialty support with certifications
- Invoice Management: Automated billing with line items and tax calculation
- Payment Processing: Multiple payment methods with reference tracking
- Insurance Claims: Complete workflow from submission to approval
- Discount System: Flexible offers and promotions
- Multi-Channel Notifications: In-app, email, SMS, and push notifications
- Template Management: Customizable email and SMS templates
- Smart Scheduling: Automated appointment reminders and alerts
- Priority Handling: Urgent notifications for critical situations
- Comprehensive Audit Trails: Complete change tracking with JSON storage
- Soft Delete Support: Data recovery capabilities
- User Activity Monitoring: IP address and user agent tracking
- Medical Record Versioning: Compliance-ready version control
- Dynamic Information System: Flexible data storage for custom fields
- Working Hours Management: Configurable schedules with break times
- Employee Shift System: Detailed scheduling across organizational entities
- Contact Management: Social media and communication channels
- Framework: NestJS - Progressive Node.js framework
- Language: TypeScript - Type-safe JavaScript
- Database: MySQL - Relational database
- ORM: TypeORM - TypeScript ORM
- Validation: Class Validator - Decorator-based validation
- Documentation: Swagger/OpenAPI - API documentation
- Testing: Jest - JavaScript testing framework
- Linting: ESLint - Code quality and style
Before you begin, ensure you have the following installed:
- Node.js (v18 or higher)
- npm (v8 or higher)
- MySQL (v8.0 or higher)
- Git (for version control)
git clone <repository-url>
cd cliniva-backendnpm installCreate a .env file in the root directory:
# Application
NODE_ENV=development
PORT=3000
APP_NAME=Cliniva Backend
# Database Configuration
DB_TYPE=mysql
DB_HOST=localhost
DB_PORT=3306
DB_USERNAME=your_username
DB_PASSWORD=your_password
DB_DATABASE=cliniva_db
# JWT Configuration
JWT_SECRET=your-super-secret-jwt-key
JWT_EXPIRES_IN=24h
# Email Configuration (Optional)
SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
SMTP_USER=your-email@gmail.com
SMTP_PASS=your-app-password
# SMS Configuration (Optional)
SMS_API_KEY=your-sms-api-key
SMS_SENDER_ID=CLINIVA
# File Upload (Future)
UPLOAD_DEST=./uploads
MAX_FILE_SIZE=10485760
# Redis (Optional - for caching)
REDIS_HOST=localhost
REDIS_PORT=6379CREATE DATABASE cliniva_db CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;# Generate migration files
npm run migration:generate -- -n InitialSchema
# Run migrations
npm run migration:runnpm run seed# Start with file watching
npm run start:dev
# Start in debug mode
npm run start:debug# Build the application
npm run build
# Start production server
npm run start:prodThe API will be available at http://localhost:3000
Once the application is running, you can access:
- Swagger UI:
http://localhost:3000/api- Interactive API documentation - OpenAPI JSON:
http://localhost:3000/api-json- Raw OpenAPI specification
# Run unit tests
npm run test
# Run e2e tests
npm run test:e2e
# Generate test coverage
npm run test:cov
# Run tests in watch mode
npm run test:watchcliniva-backend/
├── src/
│ ├── auth/ # Authentication & authorization
│ ├── users/ # User management
│ ├── organizations/ # Organization entities
│ ├── complexes/ # Complex management
│ ├── clinics/ # Clinic operations
│ ├── departments/ # Department management
│ ├── patients/ # Patient records
│ ├── appointments/ # Appointment scheduling
│ ├── services/ # Medical services
│ ├── specialties/ # Doctor specialties
│ ├── medical-reports/ # Medical documentation
│ ├── billing/ # Invoice & payment management
│ ├── notifications/ # Communication system
│ ├── common/ # Shared utilities
│ ├── config/ # Configuration modules
│ └── database/ # Database entities & migrations
├── test/ # Test files
├── docs/ # Documentation
└── dist/ # Compiled output
The application uses a comprehensive database schema designed for multi-tenant healthcare operations. See ../docs/database-schema.md for detailed schema documentation.
- Organizations & Complexes: Multi-level organizational structure
- Users & Access Control: Role-based permission system
- Patients & Appointments: Core healthcare operations
- Medical Reports: Digital medical records
- Billing System: Invoices, payments, and insurance claims
- Notifications: Multi-channel communication
# Create feature branch
git checkout -b feature/appointment-scheduling
# Make changes and commit
git add .
git commit -m "feat: add appointment scheduling module"
# Push to remote
git push origin feature/appointment-scheduling# Generate migration for schema changes
npm run migration:generate -- -n AddAppointmentReminders
# Review and edit migration file
# Run migration
npm run migration:run# Lint code
npm run lint
# Fix linting issues
npm run lint:fix
# Format code
npm run format- User authentication & authorization
- Organization & clinic management
- Patient registration & management
- Appointment scheduling
- Medical reports
- Invoice generation
- Payment processing
- Insurance claim management
- Financial reporting
- Notification system
- Email & SMS templates
- Appointment reminders
- Multi-channel delivery
- Patient portal integration
- Advanced analytics
- Mobile app support
- Third-party integrations
We welcome contributions! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'feat: add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
We use Conventional Commits:
feat:New featurefix:Bug fixdocs:Documentation changesstyle:Code style changesrefactor:Code refactoringtest:Adding or updating testschore:Maintenance tasks
For support and questions:
- Issues: GitHub Issues
- Documentation: Project Wiki
- Email: support@cliniva.com
This project is licensed under the MIT License - see the LICENSE file for details.
- NestJS - The progressive Node.js framework
- TypeORM - Amazing TypeScript ORM
- Class Validator - Validation made easy
Made with ❤️ for better healthcare management