FastAPI-based backend for the AI smart door security assistant.
backend/
├── app/
│ ├── main.py # FastAPI app entry point
│ ├── api/
│ │ └── routes/
│ │ ├── health.py # Health check endpoint
│ │ ├── events.py # Event management endpoints
│ │ ├── detection.py # Detection simulation endpoints
│ │ ├── voice.py # Voice/speech endpoints
│ │ └── session.py # Session management
│ ├── core/
│ │ └── config.py # App configuration & env vars
│ ├── models/
│ │ └── __init__.py # Database models (future)
│ ├── schemas/
│ │ ├── event.py # Event Pydantic schemas
│ │ ├── detection.py # Detection Pydantic schemas
│ │ └── voice.py # Voice Pydantic schemas
│ ├── services/
│ │ ├── detection/
│ │ │ ├── person_detector.py # 🔒 Patrick + Quan — OpenCV person detection
│ │ │ └── event_classifier.py # 🔒 Patrick + Quan — Event type classification
│ │ ├── audio/
│ │ │ └── microphone_service.py # 🔒 Patrick + Quan — Microphone input handling
│ │ ├── pi/
│ │ │ ├── camera_service.py # 🔒 Patrick + Quan — Pi camera streaming
│ │ │ └── pi_controller.py # 🔒 Patrick + Quan — Pi GPIO / hardware control
│ │ └── voice/
│ │ └── elevenlabs_service.py # 🔒 Tirth — ElevenLabs voice synthesis
│ └── utils/
│ └── helpers.py # Shared utility functions
├── requirements.txt
├── .env.example
└── README.md
# Create virtual environment
python -m venv venv
source venv/bin/activate
# Install dependencies
pip install -r requirements.txt
# Set up environment
cp .env.example .env
# Edit .env with your API keys
# Run the server
uvicorn app.main:app --reload --port 8000| Method | Path | Description |
|---|---|---|
| GET | /api/health |
Health check |
| POST | /api/detection/simulate |
Simulate person detection |
| GET | /api/events |
Get recent events |
| POST | /api/voice/speak |
Generate voice response |
| POST | /api/session/reset |
Reset current session |
Once running, visit:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
- detection/ — Patrick + Quan
- audio/ — Patrick + Quan
- pi/ — Patrick + Quan
- voice/ — Tirth