# naman-56-56/saarthi architecture

> Architecture diagram of the GitHub repository naman-56-56/saarthi, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-09-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/naman-56-56/saarthi
- Repository: https://github.com/naman-56-56/saarthi

## Overview

##### Project Type & Purpose
- This is a full-stack web platform (“Saarthi”) combining:
- Next.js (React + TailwindCSS) frontend under `/frontend/`
- Django REST API backend with an AI/ML recommendation engine under `saarthi/`
- PostgreSQL + Redis for data, external integrations for internship data, and containerized deployment

##### Key Architectural Components
a. User Layer (Students, Employers, Admins)
b. Frontend Layer (Next.js App Router, UI Components, Hooks, Utilities)
c. Backend Layer (Django REST Framework, Authentication, Business Logic)
d. ML Recommendation Engine (Text preprocessing, vectorization, filtering algorithms)
e. Data Layer (PostgreSQL, Redis cache, Cloud storage for media)
f. External Integrations (Internshala API, PM Portal data, Kaggle datasets)
g. Infrastructure (Docker, Kubernetes, NGINX reverse proxy/CDN)

##### Relationships & Data Flows
- Web Browser → Frontend (HTTPS)
- Frontend → Django API (REST calls)
- API → ML Engine (in-process calls)
- API → Database / Redis / Storage (SQL, cache, file APIs)
- External Data Sources → API / ML Engine (scheduled or on-demand fetch)
- Infrastructure layers (Load Balancer, Containers, CDN) wrap the entire circle

##### Architectural Patterns & Principles
- Monolithic codebase with microservices-inspired separation of concerns
- Layered architecture: Presentation → API → Business Logic → Data
- Modular React components + custom hooks for UI
- Django apps for users and recommendations, clear service boundaries
- ML engine as an internal service (scikit-learn models loaded via joblib)
- Containerization & orchestration for portability and scalability

## Diagram (Mermaid)

```mermaid
flowchart LR
    %% External boundary: Infrastructure
    style Infra stroke:#888,stroke-dasharray: 5 5,fill:transparent
    subgraph Infra["Infrastructure (Docker, K8s, NGINX)"]
    end

    %% Core components around the circle
    Infra --> Users
    Infra --> Frontend
    Infra --> API
    Infra --> ML
    Infra --> Data
    Infra --> External

    %% Nodes
    Users["User Layer\n(Browsers & Mobile)"]:::user
    Frontend["Frontend\n(Next.js)"]:::frontend
    API["API Layer\n(Django REST)"]:::api
    ML["ML Recommendation Engine"]:::ml
    Data["Data Layer\n(PostgreSQL, Redis, Storage)"]:::data
    External["External Integrations\n(Internshala, PM Portal, Kaggle)"]:::external

    %% Circular connections
    Users -->|"HTTPS"| Frontend
    Frontend -->|"REST Calls"| API
    API -->|"In-process calls"| ML
    API -->|"SQL / Cache / Storage"| Data
    ML -->|"Results"| API
    API -->|"Responses"| Frontend
    Frontend -->|"Render UI"| Users

    %% External integrations loops
    External -->|"Fetch Data"| API
    External -->|"Feed ML"| ML

    %% Click Events
    click Users "https://github.com/naman-56-56/saarthi/blob/main/frontend/app/login/page.tsx"
    click Frontend "https://github.com/naman-56-56/saarthi/blob/main/frontend/app/layout.tsx"
    click Frontend "https://github.com/naman-56-56/saarthi/tree/main/frontend/components/components/"
    click Frontend "https://github.com/naman-56-56/saarthi/blob/main/frontend/hooks/use-mobile.ts"
    click API "https://github.com/naman-56-56/saarthi/blob/main/saarthi/saarthi/urls.py"
    click API "https://github.com/naman-56-56/saarthi/blob/main/saarthi/users/views.py"
    click ML "https://github.com/naman-56-56/saarthi/blob/main/saarthi/recommendations/ml_model.py"
    click Data "https://github.com/naman-56-56/saarthi/blob/main/saarthi/saarthi/settings.py"
    click External "https://github.com/naman-56-56/saarthi/blob/main/saarthi/internships/middleware.py"

    %% Styles
    classDef user fill:#d0e8ff,stroke:#000
    classDef frontend fill:#b2f0ff,stroke:#000
    classDef api fill:#c2f0c2,stroke:#000
    classDef ml fill:#fff0b3,stroke:#000
    classDef data fill:#ffd9b3,stroke:#000
    classDef external fill:#e0ccff,stroke:#000
    classDef Infra fill:transparent,stroke:#888,stroke-dasharray:5 5
```
