# README
š„ Medical Record Backend - Secure API with JWT & Role-Based Authentication š
š Key Features
ā
JWT Authentication - Secure login and token-based access control š
ā
Role-Based Access (RBAC) - API access controlled by user roles (Admin, Doctor, Patient) š
ā
Secure API Endpoints - Restricted access to medical records based on role š”ļø
ā
Complete CRUD Operations - Supports GET
, POST
, PUT
, DELETE
, and UPDATE
methods š
ā
Doctor-Patient Interaction Tracking - Stores records of conversations securely š
ā
Scalable & Optimized - Built with Go (Golang) and Fiber for high performance ā”
š ļø Tech Stack
- š Golang - High-performance backend
- ā” Fiber - Lightweight & fast web framework
- šļø PostgreSQL - Reliable database
- š JWT Authentication - Secure API access
- š Role-Based Access Control (RBAC) - Fine-grained permissions
- š” Docker (Future Scope) - Containerized deployment
š How to Set Up Locally
š¹ Prerequisites
1ļøā£ Install Go (v1.19+) š ļø
2ļøā£ Install PostgreSQL - PostgreSQL v.16šļø
3ļøā£ Clone the repository
git clone https://github.com/PragaL15/med_admin_backend
4ļøā£ Install dependencies š¦
go mod tidy
go get import_file_name
5ļøā£ Create a .env file for environment variables š
PORT=4000
DB_HOST=localhost
DB_USER=your_username
DB_PASSWORD=your_password
DB_NAME=medical_db
JWT_SECRET=your_secret_key
6ļøā£ Run the server š
go run main.go
Now, the backend is running on http://localhost:4000
š
š Project Structure
medical_record/
āāā handlers/ # API handlers (Patients, Doctors, Conversations)
āāā middleware/ # JWT Authentication & Role-Based Access Control
āāā routes/ # API Route definitions
āāā db/ # Database connection setup
āāā models/ # Database models & schemas
āāā main.go # Main entry point of the server
āāā go.mod # Go module dependencies
āāā .env # Environment variables (Port, DB config, JWT secret)
š Authentication & Role-Based Access
š„ User Roles
- Admin šļø - Full access to all APIs (Manage doctors, patients, and records)
- Doctor 𩺠- Can fetch and update patient details, add medical records
- Patient š§āāļø - Can only view their own records
š Secured API Paths
Role | Accessible Endpoints | Methods |
---|---|---|
Admin šļø | /users /patients /doctors /records | GET, POST, PUT, DELETE |
Doctor 𩺠| /patients /records | GET, POST, UPDATE |
Patient š§āāļø | /records/{patient_id} | GET |
š JWT Authentication is required for all API calls. Every request must include a valid token in the header:
Authorization: Bearer <your-jwt-token>
š„ Upcoming Features
- Audit Logs - Track changes to medical records š
- Two-Factor Authentication (2FA) - Extra layer of security š
- Email & SMS Notifications - Appointment reminders š©
- Docker & Kubernetes Deployment - Scalable containerized setup š³
šØāš» Contributors
š” Pragalya Kanakaraj - Backend Developer š
š License
š MIT License - Use it freely, modify it responsibly!