How danhdct122c3/smart_campus works
Purpose and Entry Points
This is a Smart Campus/employee-management platform: a React single-page frontend backed by a Python API designed for AWS Lambda, with attendance/face recognition, workforce workflows, notifications, analytics, security, and AI assistance. Frontend bootstraps at frontend/src/main.jsx and routes through frontend/src/App.jsx. Backend application assembly is in backend/app/main.py; Lambda invocation is adapted by backend/app/handler.py.
API Composition and Runtime Boundary
The backend is a modular Python API. backend/app/api/router.py is the central route aggregation boundary; each business module exposes a router and separates request schemas, service logic, and (where needed) repository access. Shared configuration, exception handling, and response conventions live in backend/app/core/config.py, backend/app/core/exceptions.py, and backend/app/core/responses.py. Environment values are represented by backend/.env.example.
Identity, Users, and Access Control
Authentication and user lifecycle are centered in backend/app/modules/auth/router.py, backend/app/modules/auth/service.py, and backend/app/modules/users/service.py. The frontend retains session/auth state in frontend/src/context/AuthContext.jsx and enforces UI access through frontend/src/components/ProtectedRoute.jsx. AWS Cognito setup is represented by aws-image/setupCognito; IAM provisioning is represented by aws-image/setupIAM.
Attendance and Biometric Flow
Attendance processing combines API handling, persistence, and policy evaluation: backend/app/modules/attendance/router.py, backend/app/modules/attendance/service.py, and backend/app/modules/attendance/rule_engine.py. Face enrollment/recognition is isolated in backend/app/modules/faces/service.py and its repository. These modules cross the AWS service boundary through backend/app/shared/aws/rekognition.py, with deployment provisioning indicated by aws-image/setupRekognition.
Operational Domain Modules
Employee-facing workflow APIs are organized by bounded domain: leave requests in backend/app/modules/leaves/service.py, task management in backend/app/modules/tasks/service.py, and notification delivery/state in backend/app/modules/notifications/service.py. Administration/security controls are handled by backend/app/modules/security/service.py and backend/app/modules/security/settings_repo.py. The corresponding SPA pages are frontend/src/pages/Leaves.jsx, frontend/src/pages/Tasks.jsx, and frontend/src/pages/Notifications.jsx.
Asynchronous Events, Notifications, and Analytics
Workers separate non-request processing from API execution: backend/app/workers/notification_worker.py, backend/app/workers/analytics_worker.py, and backend/app/workers/security_worker.py. Event and messaging integrations are encapsulated in backend/app/shared/aws/eventbridge.py and backend/app/shared/aws/sns.py; infrastructure folders also indicate EventBridge, SQS, SES, and CloudWatch usage (aws-image/setupEvenBridge, aws-image/setupSQS, aws-image/setupSES, aws-image/setupCloudWatch). Reporting services/repositories in backend/app/modules/reports/service.py and backend/app/modules/reports/repository.py likely consume Athena through backend/app/shared/aws/athena.py.
AI, Data, and AWS Deployment Surface
The AI assistant API is implemented in backend/app/modules/ai_assistant/service.py and reaches Amazon Bedrock via backend/app/shared/aws/bedrock.py; its client page is frontend/src/pages/AIAssistant.jsx. Persistence and object storage adapters are backend/app/shared/aws/dynamodb.py and backend/app/shared/aws/s3.py, with AWS setup coverage for DB, S3, Lambda, API, CloudFront, WAF, X-Ray, and CodePipeline under aws-image/. CI build entry points are buildspec-backend.yml and buildspec-frontend.yml.
Main entry points: router.py Route Aggregation · main.jsx SPA Bootstrap & Routes · attendance/service.py Attendance Policy · leaves/service.py Workforce Workflows
Components 21
React SPA
- SPA Bootstrap & Routes
frontend/src/main.jsx - Auth State & Route Guard
frontend/src/context/AuthContext.jsx - Workflow Pages · Leave, task, and notification user workflows.
frontend/src/pages/Leaves.jsx - AI Assistant Page
frontend/src/pages/AIAssistant.jsx
Python API
- Lambda Adapter
backend/app/handler.py - Application Assembly
backend/app/main.py - Route Aggregation
backend/app/api/router.py - Identity & Users · Authentication, lifecycle, and access control.
backend/app/modules/auth/service.py - Attendance Policy · Attendance processing and rule evaluation.
backend/app/modules/attendance/service.py - Face Recognition · Enrollment and recognition with repository access.
backend/app/modules/faces/service.py - Workforce Workflows · Leave, tasks, notifications, and security administration.
backend/app/modules/leaves/service.py - Reporting
backend/app/modules/reports/service.py - AI Assistant
backend/app/modules/ai_assistant/service.py
Async Processing
- Event Workers · Notification, analytics, and security processing.
backend/app/workers/notification_worker.py - Events & Messaging · EventBridge and SNS integration boundary.
backend/app/shared/aws/eventbridge.py
AWS Platform
- Cognito & IAM
aws-image/setupCognito - Amazon Rekognition
backend/app/shared/aws/rekognition.py - DynamoDB & S3
backend/app/shared/aws/dynamodb.py - Amazon Athena
backend/app/shared/aws/athena.py - Amazon Bedrock
backend/app/shared/aws/bedrock.py - Build & Deployment · Backend and frontend build specifications feed AWS deployment.
buildspec-backend.yml
Connections 26
- SPA Bootstrap & Routes → Auth State & Route Guard: provides session
- SPA Bootstrap & Routes → Workflow Pages: routes to
- SPA Bootstrap & Routes → AI Assistant Page: routes to
- Auth State & Route Guard → Route Aggregation: authenticated API calls
- Workflow Pages → Route Aggregation: workflow API calls
- AI Assistant Page → Route Aggregation: assistant requests
- Lambda Adapter → Application Assembly: invokes
- Application Assembly → Route Aggregation: mounts
- Route Aggregation → Identity & Users: auth and users
- Route Aggregation → Attendance Policy: attendance endpoints
- Route Aggregation → Workforce Workflows: workflow endpoints
- Route Aggregation → Reporting: report endpoints
- Route Aggregation → AI Assistant: assistant endpoint
- Identity & Users → Cognito & IAM: identity integration
- Attendance Policy → Face Recognition: uses recognition
- Face Recognition → Amazon Rekognition: recognizes faces
- Attendance Policy → DynamoDB & S3: persists records
- Workforce Workflows → DynamoDB & S3: persists workflow state
- Workforce Workflows → Events & Messaging: publishes events
- Events & Messaging → Event Workers: triggers async work
- Event Workers → DynamoDB & S3: reads and updates state
- Event Workers → Amazon Athena: processes analytics
- Reporting → Amazon Athena: queries analytics
- AI Assistant → Amazon Bedrock: generates responses
- Build & Deployment → SPA Bootstrap & Routes: builds frontend
- Build & Deployment → Lambda Adapter: deploys backend