Skip to content

Commit b22ff46

Browse files
Fixed: Api auth bugs
1 parent fd36abe commit b22ff46

File tree

14 files changed

+503
-317
lines changed

14 files changed

+503
-317
lines changed

.gitignore

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,48 @@
11
client/
2+
# Python
3+
__pycache__/
4+
*.py[cod]
5+
*.egg-info/
6+
*.log
7+
.pytest_cache/
8+
venv/
9+
env/
10+
.venv/
211
.env
312

13+
# Docker
14+
docker-compose.override.yml
15+
docker-data/
16+
17+
# IDE
18+
.vscode/
19+
.idea/
20+
*.swp
21+
*.swo
22+
23+
# Build/Test
24+
dist/
25+
build/
26+
.coverage
27+
htmlcov/
28+
29+
# Database
30+
*.db
31+
*.sqlite3
32+
33+
# Secrets
34+
*.key
35+
*.pem
36+
credentials.json
37+
secrets/
38+
39+
# Frontend (if added later)
40+
node_modules/
41+
npm-debug.log*
42+
yarn-debug.log*
43+
yarn-error.log*
44+
45+
# Misc
46+
.DS_Store
47+
*.bak
48+
*.tmp

API_EXAMPLES.http

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# API_EXAMPLES.http
2+
3+
```markdown
4+
# API Request Examples
5+
6+
### Authentication
7+
```http
8+
POST http://localhost:8000/api/auth/login
9+
Content-Type: application/json
10+
11+
{
12+
"email": "patient@example.com",
13+
"password": "securePassword123!"
14+
}
15+
```
16+
17+
### Patient Management
18+
```http
19+
GET http://localhost:8000/api/patients/me
20+
Authorization: Bearer {{token}}
21+
```
22+
23+
### Doctor Availability
24+
```http
25+
POST http://localhost:8000/api/doctors/availability
26+
Authorization: Bearer {{token}}
27+
Content-Type: application/json
28+
29+
{
30+
"start_time": "2024-03-01T09:00:00",
31+
"end_time": "2024-03-01T17:00:00",
32+
"recurring": true
33+
}
34+
```
35+
36+
### Appointment Booking
37+
```http
38+
POST http://localhost:8000/api/appointments
39+
Authorization: Bearer {{token}}
40+
Content-Type: application/json
41+
42+
{
43+
"doctor_id": "550e8400-e29b-41d4-a716-446655440000",
44+
"scheduled_time": "2024-03-05T14:30:00",
45+
"reason": "Annual Checkup"
46+
}

ARCHITECTURE.md

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
2+
# System Architecture
3+
4+
## Microservices Diagram
5+
6+
```mermaid
7+
graph TD
8+
A[API Gateway] --> B[Authentication Service]
9+
A --> C[Patient Service]
10+
A --> D[Doctor Service]
11+
A --> E[Appointment Service]
12+
A --> F[Notification Service]
13+
E --> G[RabbitMQ]
14+
F --> G
15+
C --> H[PostgreSQL]
16+
D --> H
17+
E --> H
18+
B --> I[Redis]
19+
20+
classDef service fill:#4CAF50,stroke:#388E3C;
21+
class A,B,C,D,E,F service;
22+
```
23+
24+
## Component Breakdown
25+
26+
1. **API Gateway (FastAPI)**
27+
- Routes incoming requests
28+
- Handles rate limiting
29+
- Manages JWT validation
30+
31+
2. **Authentication Service**
32+
- OAuth2 password flow
33+
- JWT token generation
34+
- Redis session storage
35+
36+
3. **Patient Service**
37+
- Patient CRUD operations
38+
- Insurance data management
39+
- Medical records storage
40+
41+
4. **Doctor Service**
42+
- Doctor profile management
43+
- Availability scheduling
44+
- Specialization tracking
45+
46+
5. **Appointment Service**
47+
- Conflict detection system
48+
- Calendar integration
49+
- Status transitions
50+
51+
6. **Notification Service**
52+
- Email/SMS notifications
53+
- RabbitMQ message processing
54+
- Template management
55+
56+
## Data Flow
57+
1. Client → API Gateway → Service
58+
2. Services ↔ PostgreSQL (ACID transactions)
59+
3. Cross-service communication via RabbitMQ
60+
4. Redis cache for frequent queries
61+
62+
# API_EXAMPLES.http
63+
64+
```markdown
65+
# API Request Examples
66+
67+
### Authentication
68+
```http
69+
POST http://localhost:8000/api/auth/login
70+
Content-Type: application/json
71+
72+
{
73+
"email": "patient@example.com",
74+
"password": "securePassword123!"
75+
}
76+
```
77+
78+
### Patient Management
79+
```http
80+
GET http://localhost:8000/api/patients/me
81+
Authorization: Bearer {{token}}
82+
```
83+
84+
### Doctor Availability
85+
```http
86+
POST http://localhost:8000/api/doctors/availability
87+
Authorization: Bearer {{token}}
88+
Content-Type: application/json
89+
90+
{
91+
"start_time": "2024-03-01T09:00:00",
92+
"end_time": "2024-03-01T17:00:00",
93+
"recurring": true
94+
}
95+
```
96+
97+
### Appointment Booking
98+
```http
99+
POST http://localhost:8000/api/appointments
100+
Authorization: Bearer {{token}}
101+
Content-Type: application/json
102+
103+
{
104+
"doctor_id": "550e8400-e29b-41d4-a716-446655440000",
105+
"scheduled_time": "2024-03-05T14:30:00",
106+
"reason": "Annual Checkup"
107+
}

DEPLOYMENT_GUIDE.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Cloud Deployment Guide
2+
3+
## AWS Setup
4+
1. **ECS Cluster**
5+
```bash
6+
aws ecs create-cluster --cluster-name healthcare-cluster
7+
```
8+
2. **RDS PostgreSQL**
9+
- Enable Multi-AZ deployment
10+
- Set storage autoscaling
11+
- Enable automated backups
12+
13+
3. **ElastiCache Redis**
14+
```bash
15+
aws elasticache create-cache-cluster \
16+
--cache-cluster-id healthcare-redis \
17+
--engine redis \
18+
--cache-node-type cache.t3.micro
19+
```
20+
21+
## Docker Configuration
22+
```dockerfile
23+
# Production Dockerfile
24+
FROM python:3.11-slim
25+
26+
RUN pip install gunicorn==20.1.0
27+
COPY requirements.txt .
28+
RUN pip install -r requirements.txt
29+
30+
COPY . .
31+
CMD ["gunicorn", "app.main:app", "-k", "uvicorn.workers.UvicornWorker"]
32+
```
33+
34+
## SSL Configuration
35+
1. Obtain Let's Encrypt certificate:
36+
```bash
37+
certbot certonly --standalone -d api.healthcare.com
38+
```
39+
2. Nginx config:
40+
```nginx
41+
ssl_certificate /etc/letsencrypt/live/api.healthcare.com/fullchain.pem;
42+
ssl_certificate_key /etc/letsencrypt/live/api.healthcare.com/privkey.pem;
43+
```
44+
45+
## Monitoring
46+
- Prometheus metrics endpoint: `/metrics`
47+
- CloudWatch alarms for:
48+
- Database connection pool usage
49+
- API error rate (>5%)
50+
- CPU utilization (>75%)
51+
```
52+
53+
# SECURITY.md
54+
55+
```markdown

0 commit comments

Comments
 (0)