File size: 2,054 Bytes
693cb3d
b19e5b5
 
693cb3d
b19e5b5
693cb3d
 
b19e5b5
 
693cb3d
 
b19e5b5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
---
title: Audit Checklist API
emoji: 📋
colorFrom: blue
colorTo: green
sdk: docker
pinned: false
license: mit
app_port: 8000
---

# Audit Checklist FastAPI Backend

This is the backend API for the Audit Checklist React Native application.

## Features
- MongoDB Atlas integration
- REST API endpoints for audit checklists
- CORS support for mobile apps
- Health check endpoint
- User session management
- Comprehensive error handling

## API Endpoints

### Health Check
- `GET /` - Basic health check
- `GET /health` - Detailed health information

### Checklist Management
- `GET /api/checklist/{user_id}` - Get checklist for user
- `PUT /api/checklist/{user_id}` - Save/update checklist
- `GET /api/checklists` - Get all checklists (admin)
- `GET /api/checklists/by-user/{user_name}` - Get checklists by user name

### Server Information
- `GET /api/server-info` - Get server information

## Environment Variables

Set these in your Hugging Face Space settings:

- `MONGODB_URI`: Your MongoDB Atlas connection string
- `CORS_ORIGIN`: Frontend URL (optional, defaults to allow all)

## Data Structure

The API manages audit checklists with the following structure:

```json
{
  "userId": "user-1234567890",
  "title": "Checklist di Audit Operativo (38 Controlli)",
  "sections": [...],
  "metadata": {
    "userName": "John Doe",
    "savedAt": "2024-01-15T14:30:25.123Z",
    "savedAtFormatted": "15/01/2024, 14:30:25",
    "userId": "user-1234567890",
    "version": "1.0"
  }
}
```

## Usage

This API is designed to work with the Audit Checklist React Native mobile application. The mobile app sends audit data to this backend, which stores it in MongoDB Atlas with user information and timestamps.

## Deployment

This FastAPI application is deployed on Hugging Face Spaces using Docker. The application runs on port 8000 and is accessible at:

`https://ali2206-checklist.hf.space`

## Development

To run locally:

```bash
cd server
pip install -r requirements.txt
python start_server.py
```

The API will be available at `http://localhost:5000`