Skip to content

Commit 931a5aa

Browse files
committed
Update documentation with health and ready checks endpoints
1 parent b5968d1 commit 931a5aa

File tree

5 files changed

+41
-65
lines changed

5 files changed

+41
-65
lines changed

docs/getting-started/first-run.md

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,28 @@ curl http://localhost:8000/api/v1/health
3838
Expected response:
3939
```json
4040
{
41-
"status": "healthy",
42-
"timestamp": "2024-01-01T12:00:00Z"
41+
"status":"healthy",
42+
"environment":"local",
43+
"version":"0.1.0",
44+
"timestamp":"2025-10-21T14:40:14+00:00"
45+
}
46+
```
47+
48+
**Ready Check:**
49+
```bash
50+
curl http://localhost:8000/api/v1/ready
51+
```
52+
53+
Expected response:
54+
```json
55+
{
56+
"status":"healthy",
57+
"environment":"local",
58+
"version":"0.1.0",
59+
"app":"healthy",
60+
"database":"healthy",
61+
"redis":"healthy",
62+
"timestamp":"2025-10-21T14:40:47+00:00"
4363
}
4464
```
4565

docs/getting-started/index.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ Visit these URLs to confirm everything is working:
104104
- **API Documentation**: [http://localhost:8000/docs](http://localhost:8000/docs)
105105
- **Alternative Docs**: [http://localhost:8000/redoc](http://localhost:8000/redoc)
106106
- **Health Check**: [http://localhost:8000/api/v1/health](http://localhost:8000/api/v1/health)
107+
- **Ready Check**: [http://localhost:8000/api/v1/ready](http://localhost:8000/api/v1/ready)
107108

108109
## You're Ready!
109110

@@ -126,7 +127,12 @@ Try these quick tests to see your API in action:
126127
curl http://localhost:8000/api/v1/health
127128
```
128129

129-
### 2. Create a User
130+
### 2. Ready Check
131+
```bash
132+
curl http://localhost:8000/api/v1/ready
133+
```
134+
135+
### 3. Create a User
130136
```bash
131137
curl -X POST "http://localhost:8000/api/v1/users" \
132138
-H "Content-Type: application/json" \
@@ -138,7 +144,7 @@ curl -X POST "http://localhost:8000/api/v1/users" \
138144
}'
139145
```
140146

141-
### 3. Login
147+
### 4. Login
142148
```bash
143149
curl -X POST "http://localhost:8000/api/v1/login" \
144150
-H "Content-Type: application/x-www-form-urlencoded" \

docs/getting-started/installation.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -290,9 +290,10 @@ After installation, verify everything works:
290290

291291
1. **API Documentation**: http://localhost:8000/docs
292292
2. **Health Check**: http://localhost:8000/api/v1/health
293-
3. **Database Connection**: Check logs for successful connection
294-
4. **Redis Connection**: Test caching functionality
295-
5. **Background Tasks**: Submit a test job
293+
3. **Ready Check**: http://localhost:8000/api/v1/ready
294+
4. **Database Connection**: Check logs for successful connection
295+
5. **Redis Connection**: Test caching functionality
296+
6. **Background Tasks**: Submit a test job
296297

297298
## Troubleshooting
298299

docs/user-guide/configuration/environment-variables.md

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -526,21 +526,6 @@ if settings.ENABLE_ADVANCED_CACHING:
526526
pass
527527
```
528528

529-
### Health Checks
530-
531-
Configure health check endpoints:
532-
533-
```python
534-
@app.get("/health")
535-
async def health_check():
536-
return {
537-
"status": "healthy",
538-
"database": await check_database_health(),
539-
"redis": await check_redis_health(),
540-
"version": settings.APP_VERSION
541-
}
542-
```
543-
544529
## Configuration Validation
545530

546531
### Environment Validation

docs/user-guide/production.md

Lines changed: 7 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,13 @@ http {
318318
access_log off;
319319
}
320320
321+
# Ready check endpoint (no rate limiting)
322+
location /ready {
323+
proxy_pass http://fastapi_backend;
324+
proxy_set_header Host $host;
325+
access_log off;
326+
}
327+
321328
# Static files (if any)
322329
location /static/ {
323330
alias /code/static/;
@@ -554,49 +561,6 @@ DEFAULT_RATE_LIMIT_LIMIT = 100 # requests per period
554561
DEFAULT_RATE_LIMIT_PERIOD = 3600 # 1 hour
555562
```
556563

557-
### Health Checks
558-
559-
#### Application Health Check
560-
561-
```python
562-
# src/app/api/v1/health.py
563-
from fastapi import APIRouter, Depends, HTTPException
564-
from sqlalchemy.ext.asyncio import AsyncSession
565-
from ...core.db.database import async_get_db
566-
from ...core.utils.cache import redis_client
567-
568-
router = APIRouter()
569-
570-
@router.get("/health")
571-
async def health_check():
572-
return {"status": "healthy", "timestamp": datetime.utcnow()}
573-
574-
@router.get("/health/detailed")
575-
async def detailed_health_check(db: AsyncSession = Depends(async_get_db)):
576-
health_status = {"status": "healthy", "services": {}}
577-
578-
# Check database
579-
try:
580-
await db.execute("SELECT 1")
581-
health_status["services"]["database"] = "healthy"
582-
except Exception:
583-
health_status["services"]["database"] = "unhealthy"
584-
health_status["status"] = "unhealthy"
585-
586-
# Check Redis
587-
try:
588-
await redis_client.ping()
589-
health_status["services"]["redis"] = "healthy"
590-
except Exception:
591-
health_status["services"]["redis"] = "unhealthy"
592-
health_status["status"] = "unhealthy"
593-
594-
if health_status["status"] == "unhealthy":
595-
raise HTTPException(status_code=503, detail=health_status)
596-
597-
return health_status
598-
```
599-
600564
### Deployment Process
601565

602566
#### CI/CD Pipeline (GitHub Actions)

0 commit comments

Comments
 (0)