# vijethph/placementcell architecture

> Architecture diagram of the GitHub repository vijethph/placementcell, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/vijethph/placementcell
- Repository: https://github.com/vijethph/placementcell

## Overview

##### Main System Components

a) Frontend Layer (React + TypeScript):
- Main feature modules:
- Authentication (Login/Register)
- Quiz System
- Discussion Forum
- IDE/Code Compiler
- Video Learning
- Companies Dashboard
- User Profile

b) Backend Layer (Node.js + Express):
- API Routes (/users, /discussions, /companies, /videos, /questions, /codes)
- Authentication Middleware
- External API Integration (HackerEarth)

c) Database Layer (MongoDB):
- Data Models:
- User
- Company
- Discussion
- Quiz
- Video

**[Client Layer (React)]**
- ↕
**[API Gateway/Express Routes]**
- ↕
**[Business Logic Layer]**
- ↕
**[Data Access Layer]**
- ↕
**[MongoDB Database]**

##### Specific Elements

a) Client-Side Components:
- Service layer (UserFunctions.tsx)
- State management flow

b) Server-Side Components:
- Express route handlers
- Authentication middleware
- External API connector (HackerEarth)
- Logger service

c) Data Flow:
- REST API calls between frontend and backend
- Database operations
- External API communications

##### Important Relationships to Highlight

- Authentication flow from login/register to protected routes
- IDE's connection to HackerEarth API
- Demonstrate the quiz flow from question retrieval to submission
- How the discussion forum interactions work

##### Technical Details

- TypeScript integration on both frontend and backend
- Docker containerization setup
- MongoDB connection configuration
- API endpoints and their purposes
- Authentication token flow

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        FE[Frontend SPA]
        App["App Component"]:::frontend
        
        subgraph "Frontend Components"
            Auth["Authentication"]:::frontend
            Login["Login Component"]:::frontend
            Register["Register Component"]:::frontend
            Quiz["Quiz System"]:::frontend
            QuizSum["Quiz Summary"]:::frontend
            Forum["Discussion Forum"]:::frontend
            IDE["Code IDE"]:::frontend
            Videos["Video Learning"]:::frontend
            Companies["Companies Dashboard"]:::frontend
            Profile["User Profile"]:::frontend
            UserFn["User Functions Service"]:::frontend
        end
    end

    subgraph "API Gateway"
        API["Express Router"]:::backend
        Auth_MW["Authentication Middleware"]:::security
        Logger["Logger Service"]:::service
    end

    subgraph "Business Logic"
        UserRoutes["User Routes"]:::backend
        QuizRoutes["Quiz Routes"]:::backend
        DiscRoutes["Discussion Routes"]:::backend
        CodeRoutes["Code Routes"]:::backend
        VideoRoutes["Video Routes"]:::backend
        CompanyRoutes["Company Routes"]:::backend
    end

    subgraph "Data Layer"
        UserModel["User Model"]:::data
        QuizModel["Quiz Model"]:::data
        DiscModel["Discussion Model"]:::data
        VideoModel["Video Model"]:::data
        CompanyModel["Company Model"]:::data
    end

    DB[(MongoDB)]:::database
    HackerEarth["HackerEarth API"]:::external

    %% Frontend Connections
    FE --> App
    App --> Auth
    Auth --> Login
    Auth --> Register
    App --> Quiz
    Quiz --> QuizSum
    App --> Forum
    App --> IDE
    App --> Videos
    App --> Companies
    App --> Profile
    App --> UserFn

    %% API Gateway Connections
    UserFn --> API
    API --> Auth_MW
    Auth_MW --> Logger

    %% Business Logic Connections
    Auth_MW --> UserRoutes
    Auth_MW --> QuizRoutes
    Auth_MW --> DiscRoutes
    Auth_MW --> CodeRoutes
    Auth_MW --> VideoRoutes
    Auth_MW --> CompanyRoutes

    %% Data Layer Connections
    UserRoutes --> UserModel
    QuizRoutes --> QuizModel
    DiscRoutes --> DiscModel
    VideoRoutes --> VideoModel
    CompanyRoutes --> CompanyModel

    %% Database Connections
    UserModel --> DB
    QuizModel --> DB
    DiscModel --> DB
    VideoModel --> DB
    CompanyModel --> DB

    %% External API Connection
    CodeRoutes --> HackerEarth

    %% Click Events
    click Login "https://github.com/vijethph/PlacementCell/blob/master/client/src/components/Login.tsx"
    click Register "https://github.com/vijethph/PlacementCell/blob/master/client/src/components/Register.tsx"
    click Quiz "https://github.com/vijethph/PlacementCell/blob/master/client/src/components/Quiz.tsx"
    click QuizSum "https://github.com/vijethph/PlacementCell/blob/master/client/src/components/QuizSummary.tsx"
    click Forum "https://github.com/vijethph/PlacementCell/blob/master/client/src/components/Forum.tsx"
    click IDE "https://github.com/vijethph/PlacementCell/blob/master/client/src/components/IDE.tsx"
    click Videos "https://github.com/vijethph/PlacementCell/blob/master/client/src/components/VideosList.tsx"
    click Companies "https://github.com/vijethph/PlacementCell/blob/master/client/src/components/CompaniesList.tsx"
    click Profile "https://github.com/vijethph/PlacementCell/blob/master/client/src/components/Profile.tsx"
    click UserFn "https://github.com/vijethph/PlacementCell/blob/master/client/src/services/UserFunctions.tsx"
    click App "https://github.com/vijethph/PlacementCell/blob/master/client/src/App.tsx"
    click Auth_MW "https://github.com/vijethph/PlacementCell/blob/master/src/authenticate.ts"
    click Logger "https://github.com/vijethph/PlacementCell/blob/master/src/logger.ts"
    click UserModel "https://github.com/vijethph/PlacementCell/blob/master/src/models/User.ts"
    click CompanyModel "https://github.com/vijethph/PlacementCell/blob/master/src/models/Company.ts"
    click DiscModel "https://github.com/vijethph/PlacementCell/blob/master/src/models/Discussion.ts"
    click VideoModel "https://github.com/vijethph/PlacementCell/blob/master/src/models/Video.ts"
    click QuizRoutes "https://github.com/vijethph/PlacementCell/blob/master/src/routes/questions.ts"
    click DiscRoutes "https://github.com/vijethph/PlacementCell/blob/master/src/routes/discussions.ts"
    click CodeRoutes "https://github.com/vijethph/PlacementCell/blob/master/src/routes/codes.ts"
    click VideoRoutes "https://github.com/vijethph/PlacementCell/blob/master/src/routes/videos.ts"
    click CompanyRoutes "https://github.com/vijethph/PlacementCell/blob/master/src/routes/companies.ts"
    click UserRoutes "https://github.com/vijethph/PlacementCell/blob/master/src/routes/users.ts"

    %% Styling
    classDef frontend fill:#2196F3,color:white
    classDef backend fill:#4CAF50,color:white
    classDef security fill:#f44336,color:white
    classDef service fill:#9C27B0,color:white
    classDef data fill:#FFC107,color:black
    classDef database fill:#FF9800,color:white
    classDef external fill:#607D8B,color:white
```
