How 31133498/eyeon-api works
Project Type & Purpose
• This is a monolithic backend REST API built with NestJS.
• It serves as the core of an AI-powered CCTV system (“Witness API”), responsible for ingesting camera data, running predictions, storing events, and exposing endpoints for a dashboard or other clients.
High-Level Architecture Components
a. Edge Component
• CCTV Cameras (external hardware or streaming service)
b. AI/Inference Layer
• An external or embedded ML service that analyzes camera feeds and emits “alerts.”
c. Backend API (NestJS monolith)
• Modules:
• Auth (JWT/local strategies, guards)
• Cameras (CRUD operations for camera metadata)
• Alerts (create/read/update alert events)
• Analytics (aggregate/query historical alert data)
• Users (user management)
• Dashboard (API endpoints for UI metrics)
• Cross-cutting: Filters (exception handling), Guards (authorization), Strategies (JWT/local)
d. Persistence
• Relational or NoSQL Database (entities for users, cameras, alerts)
e. External Services
• Notification/email/SMS service (to send real-time alerts)
f. Client UIs
• Web Dashboard or Mobile App consuming the API
Data & Control Flow
1. Cameras stream video →
2. AI service processes frames →
3. When a crime is predicted, AI “pushes” an alert to the Alerts API →
4. Alerts module writes to DB; Analytics module may consume or aggregate these →
5. Dashboard/UI polls or subscribes for new data via the Dashboard and Analytics endpoints →
6. Auth module secures all endpoints using JWT tokens
Architectural Patterns & Principles
• Layered architecture: Controllers → Services → Repositories/Entities
• Feature-based modularization: each module encapsulates related DTOs, controllers, services, and entities
• Cross-cutting concerns (auth, error handling) centralized under src/common
• Dependency injection (NestJS) to wire controllers/services/strategies
Technologies & Frameworks
• Node.js, NestJS framework
• TypeScript, decorators, DI container
• JWT for authentication, Passport strategies (local/jwt)
• TypeORM or another ORM (entities under each module)
• Environment configuration via .env, nest-cli, tsconfig
Key Points to Capture
• Feature modules and their boundaries
• Central role of Auth and Guards for security
• Data flow from cameras → AI → alerts → persistence → analytics/dashboard
• Integration points with external systems (AI inference, notifications)