How thetimemachine01/facedec works
Project type and purpose
• From the README and file tree, this is a two-part system:
• A React Native mobile application for end-users (employees/students) to check in/out via face recognition.
• A Spring Boot monolith backend providing REST APIs for authentication, attendance, face detection orchestration, and data persistence.
• Purpose: automate attendance via real-time face detection, secure user management, and generate attendance logs.
File structure
• Top-level artifacts:
• Dockerfile, docker-compose.yml → containerized deployment of backend + database.
• pom.xml, mvnw → Spring Boot build.
• src/main/java/com/application/facedec → layered code (controller, service, repository, config, dto, entity, exceptions).
• src/main/resources/db/migration → Flyway SQL migrations.
• OpenCV Haarcascade XML in resources → face detection model.
• Patterns & frameworks:
• Layered MVC: Controllers → Services → Repositories (JPA).
• Spring Security with JWT filters.
• Face detection integrated via OpenCVConfig in controller layer.
• Database migrations via Flyway.
README for additional insights
• Tech stack: React Native (mobile), Spring Boot (backend), unspecified RDBMS, Docker for deployment.
• Features: real-time face detection, user management, attendance tracking, notifications.
• Future scope indicates an admin web front-end (not yet implemented) and external integrations (HR/payroll).
a. Main components:
1. Mobile Application (React Native)
2. API Gateway / Spring Boot Backend
– Controllers (AuthController, AttendanceController, FaceDetectionController, HealthController)
– Security Layer (JWTAuthenticationFilter, SecurityConfig, JwtTokenProvider)
– Service Layer (AuthService, AttendanceService, FaceDetectionService, EmployeeService, UserService)
– Data Access Layer (JPA Repositories)
3. Database (PostgreSQL/MySQL) with Flyway migrations
4. Face Detection Engine (OpenCV + haarcascade XML)
5. External Services (e.g., Notification Service, Email/SMS gateway)
6. Infrastructure (Docker containers via docker-compose, truststore for SSL/TLS)
b. Relationships & interactions:
• Mobile App ⇄ Backend REST API (HTTPS, JWT bearer tokens)
• Backend Security Layer intercepts requests → authenticates/authorizes via JWT and CustomUserDetailsService
• Controllers delegate to Services → business logic
• Services call Repositories → CRUD on DB
• FaceDetectionService loads Haarcascade via OpenCVConfig, uses camera capture data from mobile to detect & match face→ updates attendance record
• Flyway applies migrations at startup
• Docker-Compose orchestrates backend + DB containers
c. Architectural patterns & design principles:
• Layered architecture (presentation → service → repository)
• Dependency Injection (Spring)
• Single monolithic deployable service (no microservices yet)
• Security by design: JWT, HTTPS, truststore
• CI/CD via GitHub Actions (main.yml)
d. Key technologies & frameworks:
• React Native (front-end)
• Spring Boot, Spring Security, JWT
• OpenCV (face detection)
• Flyway (DB migrations)
• JPA/Hibernate
• Docker & Docker-Compose
Essential architectural elements to capture
• Layered package structure: config, controller, dto, entity, repository, service, exceptions
• JWT authentication flow and token storage (RefreshToken entity/repository)
• Face detection component (OpenCVConfig + haarcascade XML → FaceDetectionService → FaceDetectionRepository)
• Flyway migration scripts (V1, V2, V3)
• Dockerized deployment and CI pipeline