# kaleblee146/cecs-491b-project architecture

> Architecture diagram of the GitHub repository kaleblee146/cecs-491b-project, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kaleblee146/cecs-491b-project
- Repository: https://github.com/kaleblee146/cecs-491b-project

## Overview

##### Project type and purpose
- This is a full-stack, AI-powered fitness application composed of:
- A Django REST backend (with analytics, user mgmt, notifications, workout planning, content)
- An iOS SwiftUI front-end (MoveMentorApp) including a real-time camera module for pose analysis
- Infrastructure for containerization (Docker, Docker-Compose) and AWS Elastic Beanstalk deployment

##### File structure
- Top-level directories:
- DjangoBackend/ – API server
– backend/ – Django project bootstrap (settings, URL routing, ASGI/WSGI, WebSocket routing for dash_app)
– analytics/, core/, notifications/, plans/, resources/, users/, workouts/ – Django apps (modular services)
– .platform/nginx/ + Dockerfile + Procfile + docker-compose.yml – deployment config for Nginx, Gunicorn, Docker
- MoveMentorApp/ – iOS app
– Managers/ – network communications (NetworkManager.swift)
– Views/ – SwiftUI screens + Camera_Components for live pose capture & AI inference model (PoseNet)
- Configuration indicates a reverse proxy (Nginx) → WSGI server (Gunicorn) → Django, plus Dockerized local development

##### README for additional insights
- REST API endpoints exposed at port 8000 for both mobile app and camera streams
- WebSocket support via Django Channels (dash_app consumers & routing) for live dashboards
- AWS EB used as production host; DB credentials managed via environment variables

##### Detail & modularity
- Camera & AI inference as a sub-component of the mobile app
- Deployment artifacts (Docker Compose services, EB config, Nginx conf)

## Diagram (Mermaid)

```mermaid
flowchart TD
  %% Frontend Layer
  subgraph "Frontend (Mobile App)" 
    direction TB
    SwiftUIApp["Mobile App (SwiftUI)"]:::frontend
    NetworkManager["NetworkManager (HTTP client)"]:::frontend
    subgraph "Camera Module" 
      direction TB
      CameraModule["Camera Module Entry"]:::frontend
      AIInference["AI Inference (PoseNet)"]:::frontend
    end
  end

  %% Backend Layer
  subgraph "Backend (Django API)" 
    direction TB
    Nginx["Reverse Proxy (Nginx)"]:::infra
    Gunicorn["WSGI Server (Gunicorn)"]:::infra
    subgraph "Django Project Bootstrap" 
      direction TB
      DjangoProject["DjangoBackend/backend"]:::backend
      Settings["Settings & URLs"]:::backend
      ASGIWSGI["ASGI/WSGI & Routing"]:::backend
      Routing["WebSocket Routing"]:::backend
    end
    subgraph "Django REST Apps"
      direction TB
      UsersService["Users Service"]:::backend
      WorkoutsService["Workouts Service"]:::backend
      AnalyticsService["Analytics Service"]:::backend
      NotificationsService["Notifications Service"]:::backend
      PlansService["Plans Service"]:::backend
      ResourcesService["Resources Service"]:::backend
    end
    subgraph "WebSocket Server (Dash App)"
      direction TB
      WebSocketServer["Django Channels Dash App"]:::backend
    end
  end

  %% Datastores & External
  subgraph "Data Stores & External Services"
    direction TB
    Database["PostgreSQL Database"]:::datastore
    S3["S3 (Media/Static Storage)"]:::datastore
    EmailService["Email/Push Service"]:::external
    ParameterStore["AWS Parameter Store"]:::external
    CloudWatch["Monitoring & Logs"]:::external
  end

  %% Infrastructure Layer
  subgraph "Infrastructure & Deployment"
    direction TB
    DockerCompose["Docker Compose (Local)"]:::infra
    DockerfileNode["Dockerfile"]:::infra
    ProcfileNode["Procfile (Gunicorn)"]:::infra
    EBConfig["AWS EB Environment"]:::infra
    ELB["API Gateway / Load Balancer"]:::infra
  end

  %% Connections
  SwiftUIApp -->|"uses"| NetworkManager
  NetworkManager -->|"HTTPS REST"| ELB
  CameraModule -->|"local inference"| AIInference
  AIInference -->|optional REST| ELB
  ELB -->|"forwards HTTP"| Nginx
  Nginx -->|"WSGI"| Gunicorn
  Gunicorn -->|"invokes"| DjangoProject
  DjangoProject -->|"loads"| Settings
  DjangoProject -->|"routes"| ASGIWSGI
  ASGIWSGI -->|"routes WS"| Routing
  DjangoProject --> UsersService
  DjangoProject --> WorkoutsService
  DjangoProject --> AnalyticsService
  DjangoProject --> NotificationsService
  DjangoProject --> PlansService
  DjangoProject --> ResourcesService
  WebSocketServer -->|WebSocket| ELB
  DjangoProject -->|ORM| Database
  DjangoProject -->|uploads/downloads| S3
  NotificationsService -->|sends| EmailService
  DjangoProject -->|reads/writes| ParameterStore
  EBConfig -->|hosting| DockerfileNode
  DockerfileNode -->|build| DockerCompose
  DockerCompose -->|local dev| Gunicorn
  EBConfig -->|behind| ELB
  ELB -->|monitors| CloudWatch

  %% Click Events
  click SwiftUIApp "https://github.com/kaleblee146/cecs-491b-project/tree/main/MoveMentorApp/MoveMentorApp"
  click NetworkManager "https://github.com/kaleblee146/cecs-491b-project/blob/main/MoveMentorApp/MoveMentorApp/Managers/NetworkManager.swift"
  click CameraModule "https://github.com/kaleblee146/cecs-491b-project/blob/main/MoveMentorApp/MoveMentorApp/Views/Camera.swift"
  click AIInference "https://github.com/kaleblee146/cecs-491b-project/tree/main/MoveMentorApp/MoveMentorApp/Views/Camera_Components/"
  click DjangoProject "https://github.com/kaleblee146/cecs-491b-project/tree/main/DjangoBackend/backend"
  click Settings "https://github.com/kaleblee146/cecs-491b-project/blob/main/DjangoBackend/backend/settings.py"
  click ASGIWSGI "https://github.com/kaleblee146/cecs-491b-project/blob/main/DjangoBackend/backend/asgi.py"
  click Routing "https://github.com/kaleblee146/cecs-491b-project/blob/main/DjangoBackend/backend/routing.py"
  click WebSocketServer "https://github.com/kaleblee146/cecs-491b-project/tree/main/DjangoBackend/backend/dash_app"
  click UsersService "https://github.com/kaleblee146/cecs-491b-project/tree/main/DjangoBackend/users"
  click WorkoutsService "https://github.com/kaleblee146/cecs-491b-project/tree/main/DjangoBackend/workouts"
  click AnalyticsService "https://github.com/kaleblee146/cecs-491b-project/tree/main/DjangoBackend/analytics"
  click NotificationsService "https://github.com/kaleblee146/cecs-491b-project/tree/main/DjangoBackend/notifications"
  click PlansService "https://github.com/kaleblee146/cecs-491b-project/tree/main/DjangoBackend/plans"
  click ResourcesService "https://github.com/kaleblee146/cecs-491b-project/tree/main/DjangoBackend/resources"
  click Nginx "https://github.com/kaleblee146/cecs-491b-project/blob/main/DjangoBackend/.platform/nginx/conf.d/webapp.conf"
  click DockerfileNode "https://github.com/kaleblee146/cecs-491b-project/tree/main/DjangoBackend/Dockerfile"
  click ProcfileNode "https://github.com/kaleblee146/cecs-491b-project/tree/main/DjangoBackend/Procfile"
  click DockerCompose "https://github.com/kaleblee146/cecs-491b-project/blob/main/DjangoBackend/docker-compose.yml"

  %% Styles
  classDef frontend fill:#E0F7FA,stroke:#006064,color:#006064
  classDef backend fill:#E8F5E9,stroke:#1B5E20,color:#1B5E20
  classDef infra fill:#FFF3E0,stroke:#E65100,color:#E65100
  classDef datastore fill:#ECEFF1,stroke:#607D8B,color:#37474F
  classDef external fill:#F3E5F5,stroke:#6A1B9A,color:#4A148C
```
