# aryanpatankar27/prepwise-webx-ca_updated architecture

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

- Interactive diagram: https://gitdiagram.com/aryanpatankar27/prepwise-webx-ca_updated
- Repository: https://github.com/aryanpatankar27/prepwise-webx-ca_updated

## Overview

##### Project type and purpose
- This is a full-stack web application (“PrepWise 2.0”) for intelligent exam preparation:
- Frontend: React + TypeScript + Tailwind, built with Vite
- Backend: Node.js/Express + Python/Flask microservice
- Database: MongoDB
- External AI service: Google Gemini-2.0-Flash API
- PDF text extraction: PDF.js

##### File structure
- Top-level directories:
- frontend/ – React UI, components, pages, services (API wrappers), context, assets, templates
- backend/ – Node.js server, controllers (authController.js), routes (authRoutes.js, mcqRoutes.js), models/User.js, middleware/auth.js, config/database.js
- backend/python_api/ – Flask microservice for MCQ generation (app.py, requirements.txt)
- Patterns & layers:
- Frontend uses component-based, context for auth state, services for API calls
- Backend Node.js follows MVC (models, controllers, routes)
- A separate Python microservice handles AI and PDF processing
- Config & deployment files:
- frontend/vite.config.js, tailwind.config.js, tsconfig files
- backend/package.json, .gitignore
- python_api/requirements.txt

##### README for additional insights
- Frontend developer commands, environment variables (VITE_GEMINI_API_KEY)
- Backend Flask setup, MongoDB requirements, ports (frontend:5173, backend:5000, Mongo:27017)
- Features: topic-based MCQs, PDF-based MCQs, score tracking

##### Detail
- Break out sub-components where helpful (e.g., React Context, service modules, controllers)
- Middleware layers (auth.js) between routes and controllers
- Stateful elements (MongoDB) vs. stateless services (Express, Flask)
- Essential tech stacks and ports

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Layer
    subgraph "Frontend (Browser)"
        direction TB
        React["React Frontend"]:::frontend
        Context["AuthContext"]:::frontend
        AuthService["authService.ts"]:::frontend
        MCQService["mcqService.ts"]:::frontend
        GeminiAPI["geminiApi.ts"]:::frontend
        PDFService["pdfService.ts"]:::frontend
        PDFUtils["pdfUtils.ts"]:::frontend
    end

    %% Backend API Layer
    subgraph "Backend API (Node.js/Express)"
        direction TB
        Express["Express API Server"]:::backend
        App["app.js"]:::backend
        Server["server.js"]:::backend
        DBConfig["database.js"]:::backend
        AuthController["authController.js"]:::backend
        AuthRoutes["authRoutes.js"]:::backend
        MCQRoutes["mcqRoutes.js"]:::backend
        UserModel["User.js"]:::backend
        AuthMiddleware["auth.js"]:::backend
        Package["package.json"]:::backend
    end

    %% Microservice Layer
    subgraph "Flask MCQ Service"
        direction TB
        FlaskService["Flask Service"]:::microservice
        AppPy["app.py"]:::microservice
        Requirements["requirements.txt"]:::microservice
    end

    %% Database and External
    MongoDB[(MongoDB Database)]:::database
    GeminiExt["Google Gemini AI API"]:::external

    %% Data Flows
    React -->|"HTTP: Auth, MCQ Endpoints"| Express
    Express -->|"CRUD via Mongoose"| MongoDB
    Express -->|"POST /generate-mcq"| FlaskService
    FlaskService -->|"AI Request"| GeminiExt
    FlaskService -->|"PDF Extraction"| PDFUtils
    Express -->|"JSON Responses"| React

    %% Click Events - Frontend
    click React "https://github.com/aryanpatankar27/prepwise-webx-ca_updated/tree/main/frontend/"
    click Context "https://github.com/aryanpatankar27/prepwise-webx-ca_updated/blob/main/frontend/src/context/AuthContext.tsx"
    click AuthService "https://github.com/aryanpatankar27/prepwise-webx-ca_updated/blob/main/frontend/src/services/authService.ts"
    click MCQService "https://github.com/aryanpatankar27/prepwise-webx-ca_updated/blob/main/frontend/src/services/mcqService.ts"
    click GeminiAPI "https://github.com/aryanpatankar27/prepwise-webx-ca_updated/blob/main/frontend/src/services/geminiApi.ts"
    click PDFService "https://github.com/aryanpatankar27/prepwise-webx-ca_updated/blob/main/frontend/src/services/pdfService.ts"
    click PDFUtils "https://github.com/aryanpatankar27/prepwise-webx-ca_updated/blob/main/frontend/src/utils/pdfUtils.ts"

    %% Click Events - Backend
    click App "https://github.com/aryanpatankar27/prepwise-webx-ca_updated/blob/main/backend/app.js"
    click Server "https://github.com/aryanpatankar27/prepwise-webx-ca_updated/blob/main/backend/server.js"
    click DBConfig "https://github.com/aryanpatankar27/prepwise-webx-ca_updated/blob/main/backend/config/database.js"
    click AuthController "https://github.com/aryanpatankar27/prepwise-webx-ca_updated/blob/main/backend/controllers/authController.js"
    click AuthRoutes "https://github.com/aryanpatankar27/prepwise-webx-ca_updated/blob/main/backend/routes/authRoutes.js"
    click MCQRoutes "https://github.com/aryanpatankar27/prepwise-webx-ca_updated/blob/main/backend/routes/mcqRoutes.js"
    click UserModel "https://github.com/aryanpatankar27/prepwise-webx-ca_updated/blob/main/backend/models/User.js"
    click AuthMiddleware "https://github.com/aryanpatankar27/prepwise-webx-ca_updated/blob/main/backend/middleware/auth.js"
    click Package "https://github.com/aryanpatankar27/prepwise-webx-ca_updated/blob/main/backend/package.json"

    %% Click Events - Python Service
    click AppPy "https://github.com/aryanpatankar27/prepwise-webx-ca_updated/blob/main/backend/python_api/app.py"
    click Requirements "https://github.com/aryanpatankar27/prepwise-webx-ca_updated/blob/main/backend/python_api/requirements.txt"

    %% Styles
    classDef frontend fill:#D6EAF8,stroke:#1B4F72,color:#1B2631
    classDef backend fill:#D5F5E3,stroke:#186A3B,color:#0B5345
    classDef microservice fill:#FCF3CF,stroke:#B9770E,color:#7E5109
    classDef database fill:#FADBD8,stroke:#922B21,color:#641E16
    classDef external fill:#E8DAEF,stroke:#6C3483,color:#4A235A
```
