Loading repository data…
Loading repository data…
hichamimlahi / repository
A cloud-native Pharmacy Management System utilizing an event-driven microservices architecture. Built with Node.js, MongoDB, and RabbitMQ, it features stateless JWT authentication, isolated REST APIs for medication inventory and medical prescriptions, and full Docker containerization for seamless deployment.
A transparent discovery signal based on current public GitHub metadata.
This score does not audit code, security, maintainers, documentation quality, or suitability. Verify the repository and its current documentation before adoption.
This project is a comprehensive pharmacy management system built upon a Microservices Architecture. It provides centralized and independent management for medications, medical prescriptions, pharmacy personnel, and user authentication, complemented by an integrated asynchronous notification system using RabbitMQ.
To ensure the system is scalable, maintainable, and modern, several key technical choices were made:
Microservices are inherently complex to deploy because there are many moving parts. Docker solves this by packaging each service (Auth, Medicament, Ordonance, etc.) into its own isolated container with its own dependencies (Node.js version, libraries).
docker-compose.yml as the orchestrator. With a single command (docker-compose up), we spin up 8 different containers (6 custom services + MongoDB + RabbitMQ) connected to the same internal network, seamlessly linking them together.In a modern pharmacy system, data structures can evolve rapidly. MongoDB was chosen as the primary database for several reasons:
In a monolithic application, user sessions are often stored in memory. In a Microservices Architecture, this is impossible because requests are routed to different independent servers. We use JSON Web Tokens (JWT) to solve this:
Authentification service verifies the credentials and returns a signed JWT. This token contains the user's identity and role.Authorization: Bearer <token>) of subsequent requests. Services like Ordonance can instantly verify the token's validity without needing to query a shared session database, keeping the architecture truly decoupled and fast.The application is decomposed into isolated containerized services. This design pattern ensures high availability, independent scalability, and separation of concerns.
| Service | External Port | Internal Port | Description & Responsibilities |
|---|---|---|---|
| Authentication | 5002 | 4002 | Manages user registration, login verification, password hashing (bcryptjs), and issues JWT tokens (jsonwebtoken) for secure API access. |
| Medicament | 5000 | 4000 | Handles the pharmacy's inventory. Performs CRUD operations on medications (stock, pricing, expiration dates). |
| Ordonance | 5001 | 4001 | Manages medical prescriptions. Validates JWT tokens with the Auth service, verifies medication existence, and publishes events to RabbitMQ. |
| Personnel | 5003 | 4003 | Manages pharmacy staff records (doctors, pharmacists, etc.), including salaries, roles, and hiring dates. |
| Notification | None | Internal | An asynchronous background worker that subscribes to RabbitMQ queues and processes events (e.g., sending an email when a prescription is validated). |
| Frontend | 8080 | 80 | A Vanilla SPA (Single Page Application) acting as the UI, communicating with backend microservices via REST API calls. |
To run this project locally, ensure you have the following tools installed on your machine:
test.js script)The entire infrastructure, including databases and message brokers, is orchestrated using Docker Compose.
Clone the repository:
git clone <your-repository-url>
cd Projet
Start the infrastructure: Run the following command at the root of the project to build the images and start all containers in the background:
docker-compose up --build -d
Access the interfaces:
guest / guest)localhost:27017Stop the infrastructure: To gracefully stop and remove the containers:
docker-compose down
Below is a breakdown of the core REST API endpoints exposed by the microservices.
Port 5002)POST /auth/register: Register a new user.
{ "nom": "Dupont", "prenom": "Jean", "email": "jean@example.com", "mot_de_passe": "password", "role": "Patient" }POST /auth/login: Authenticate a user and receive a JWT.
{ "email": "jean@example.com", "mot_de_passe": "password" }{ "token": "eyJhbGciOiJIUz..." }Port 5000)POST /medicament/ajouter: Add a new medication to the inventory.
{ "nom_commercial": "Paracetamol", "quantite_stock": 100, "prix_unitaire": 5, ... }GET /medicament/liste: Retrieve the list of all medications.Port 5001)Requires JWT Token in Headers: Authorization: Bearer <token>
POST /ordonance/ajouter: Create a new prescription. Triggers a RabbitMQ event upon success.
{ "numero_ordonnance": "ORD-001", "nom_patient": "Jean", "medicaments_prescrits": [...] }Port 5003)POST /personnel/ajouter: Hire/Add a new staff member.
{ "matricule": "EMP-001", "nom": "Dr. Martin", "poste": "Médecin", ... }GET /personnel/liste: Get all active personnel.A global end-to-end test script (test.js) is provided at the root of the project. It uses axios to simulate a complete user journey across all microservices (Register -> Login -> Add Medication -> Create Prescription -> Add Personnel).
To run the test suite:
docker-compose up -d).npm install axiosnode test.js
If successful, the terminal will output "=== Tous les tests ont réussi ! ===".
Projet/
├── authentification/ # Auth microservice source code (Node.js/Express)
├── frontend/ # Static SPA (HTML, CSS, JS) served by Nginx
├── medicament/ # Medication microservice source code
├── notification/ # Async notification worker (RabbitMQ consumer)
├── ordonance/ # Prescription microservice source code
├── personnel/ # Personnel management microservice
├── docker-compose.yml # Docker orchestration and networking config
└── test.js # E2E integration test script
git checkout -b feature/NewFeature)git commit -m 'Add NewFeature')git push origin feature/NewFeature)