Skip to content

Commit df0e23f

Browse files
committed
Added
1 parent 223b350 commit df0e23f

File tree

3 files changed

+580
-0
lines changed

3 files changed

+580
-0
lines changed

schema-architecture.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
2+
3+
This Spring Boot application uses both MVC and REST controllers. Thymeleaf templates are used for the Admin and Doctor dashboards, while REST APIs serve all other modules.
4+
5+
The application interacts with two databases—MySQL (for patient, doctor, appointment, and admin data) and MongoDB (for prescriptions). All controllers route requests through a common service layer, which in turn delegates to the appropriate repositories. MySQL uses JPA entities while MongoDB uses document models.
6+
7+
8+
Section 1: Architecture Summary
9+
10+
Section 2: Numbered Flow
11+
12+
13+
1. User Interaction (UI Layer)
14+
Thymeleaf-based web dashboard
15+
REST API client
16+
17+
2. Controller Entry Point (Controller Layer)
18+
Web request - Thymeleaf Controller
19+
API request - REST Controller
20+
21+
3. Business Logic Invocation (Service Layer)
22+
23+
4. Data Access Request (Repository Layer)
24+
JPA Repositories interact with MySQL
25+
Mongo Repositories interact with MongoDB
26+
27+
5. Database Operations (Data Layer)
28+
SQL queries (for MySQL)
29+
Document operations (for MongoDB)
30+
31+
6. Model Binding (Entity/Document Mapping)
32+
MySQL - JPA @Entity classes
33+
MongoDB - @Document classes
34+
35+
7. Response Generation (UI/JSON Output)
36+
Web flow - Thymeleaf - HTML
37+
API flow - JSON - HTTP
38+
39+
40+
41+
42+

schema-design.md

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
2+
## MySQL Database Design
3+
4+
**Tables:**
5+
6+
1. patients
7+
2. doctors
8+
3. appointments
9+
4. admins
10+
5. payments
11+
6. doctor_availability
12+
7. clinic_locations
13+
14+
15+
**Table: patients**
16+
17+
|Column Name |Data Type |Constraints |
18+
|-------------|-----------------|---------------------------|
19+
|id |INT |PRIMARY KEY, AUTO_INCREMENT|
20+
|full_name |VARCHAR(100) |NOT NULL |
21+
|email |VARCHAR(150) |NOT NULL, UNIQUE |
22+
|password_hash|VARCHAR(255) |NOT NULL |
23+
|phone_number |VARCHAR(20) | |
24+
|date_of_birth|DATE | |
25+
|gender |ENUM('M','F','O')| |
26+
|created_at |TIMESTAMP |DEFAULT CURRENT_TIMESTAMP |
27+
28+
29+
**Table: doctors**
30+
31+
|Column Name |Data Type |Constraints |
32+
|--------------|-----------------|---------------------------|
33+
|id |INT |PRIMARY KEY, AUTO_INCREMENT|
34+
|full_name |VARCHAR(100) |NOT NULL |
35+
|email |VARCHAR(150) |NOT NULL, UNIQUE |
36+
|password_hash |VARCHAR(255) |NOT NULL |
37+
|specialization|VARCHAR(100) |NOT NULL |
38+
|phone_number |VARCHAR(20) | |
39+
|bio |TEXT | |
40+
|created_at |TIMESTAMP |DEFAULT CURRENT_TIMESTAMP |
41+
42+
43+
**Table: appointments**
44+
45+
|Column Name |Data Type |Constraints |
46+
|----------------|----------------------------------------|------------------------------------|
47+
|id |INT |PRIMARY KEY, AUTO_INCREMENT |
48+
|patient_id |INT |NOT NULL, FOREIGN KEY → patients(id)|
49+
|doctor_id |INT |NOT NULL, FOREIGN KEY → patients(id)|
50+
|appointment_time|DATETIME |NOT NULL |
51+
|duration_minutes|INT |DEFAULT 60 |
52+
|status |ENUM('BOOKED', 'CANCELLED', 'COMPLETED')|DEFAULT 'BOOKED' |
53+
|created_at |TIMESTAMP |DEFAULT CURRENT_TIMESTAMP |
54+
55+
56+
**Table: admins**
57+
58+
|Column Name |Data Type |Constraints |
59+
|-------------|----------------------------------------|---------------------------|
60+
|id |INT |PRIMARY KEY, AUTO_INCREMENT|
61+
|full_name |VARCHAR(100) |NOT NULL |
62+
|email |VARCHAR(150) |NOT NULL, UNIQUE |
63+
|password_hash|VARCHAR(255) |NOT NULL |
64+
|role |VARCHAR(50) |DEFAULT 'ADMIN' |
65+
|created_at |TIMESTAMP |DEFAULT CURRENT_TIMESTAMP |
66+
67+
68+
**Table: payments**
69+
70+
|Column Name |Data Type |Constraints |
71+
|--------------|-------------------------------|------------------------------|
72+
|id |INT |PRIMARY KEY, AUTO_INCREMENT |
73+
|appointment_id|INT |FOREIGN KEY → appointments(id)|
74+
|amount |DECIMAL(10,2) |NOT NULL |
75+
|payment_method|VARCHAR(50) |NOT NULL |
76+
|payment_status|ENUM('PAID','PENDING','FAILED')|DEFAULT 'PENDING' |
77+
|transaction_id|VARCHAR(100) |UNIQUE |
78+
|created_at |TIMESTAMP |DEFAULT CURRENT_TIMESTAMP |
79+
80+
81+
**Table: doctor_availability**
82+
83+
|Column Name |Data Type |Constraints |
84+
|--------------|-----------------------------------------------|---------------------------|
85+
|id |INT |PRIMARY KEY, AUTO_INCREMENT|
86+
|doctor_id |INT |FOREIGN KEY → doctors(id) |
87+
|day_of_week |ENUM('MON','TUE','WED','THU','FRI','SAT','SUN')|NOT NULL |
88+
|start_time |TIME |NOT NULL |
89+
|end_time |TIME |NOT NULL |
90+
91+
92+
**Table: clinic_locations**
93+
94+
|Column Name |Data Type |Constraints |
95+
|---------------|------------|---------------------------|
96+
|id |INT |PRIMARY KEY, AUTO_INCREMENT|
97+
|name |VARCHAR(100)|NOT NULL |
98+
|address |TEXT |NOT NULL |
99+
|phone_number |VARCHAR(20) |NOT NULL |
100+
|operating_hours|VARCHAR(100)|NOT NULL |
101+
102+
103+
104+
## MongoDB Collection Design
105+
106+
**Collection:**
107+
108+
1. prescriptions
109+
110+
**MongoDB Collection: prescriptions**
111+
112+
Relation to MySQL: appointment_id
113+
114+
115+
Example Document (prescriptions)
116+
{
117+
"_id": "746353858fhfg465473yegsa",
118+
"appointment_id": 2048,
119+
"doctor_id": 63,
120+
"patient_id": 45,
121+
"date_issued": "2025-01-01T06:23:00Z",
122+
"medications": [
123+
{
124+
"name": "Lorem ipsum",
125+
"dosage": "250mg",
126+
"frequency": "Lorem ipsum",
127+
"duration_days": 14,
128+
"notes": "Lorem ipsum"
129+
},
130+
{
131+
"name": "Lorem ipsum",
132+
"dosage": "250mg",
133+
"frequency": "Lorem ipsum",
134+
"duration_days": 7,
135+
"notes": "Lorem ipsum"
136+
}
137+
],
138+
"notes": {
139+
"chief_complaint": "Lorem ipsum dolor sit amet, consectetur adipiscing",
140+
"diagnosis": "Lorem ipsum dolor sit amet, consectetur adipiscing",
141+
"recommendations": "Lorem ipsum dolor sit amet, consectetur adipiscing"
142+
},
143+
"tags": ["Lorem ipsum", "Lorem ipsum"],
144+
"attachments": [
145+
{
146+
"type": "pdf",
147+
"file_name": "Lorem ipsum dolor sit amet, consectetur adipiscing",
148+
"url": "Lorem ipsum dolor sit amet, consectetur adipiscing"
149+
}
150+
],
151+
"created_at": "2025-01-01T06:23:00Z",
152+
"last_updated": "2025-01-01T06:23:00Z",
153+
"version": 1
154+
}
155+
156+
157+
158+
159+

0 commit comments

Comments
 (0)