# adeebmirza/intellihelper-backend architecture

> Architecture diagram of the GitHub repository adeebmirza/intellihelper-backend, 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/adeebmirza/intellihelper-backend
- Repository: https://github.com/adeebmirza/intellihelper-backend

## Overview

##### Project type and purpose
- This is a backend-only web service (monolithic API) offering features like AI-powered chat (Chatbot), news aggregation (Intelli_News), user profiles (registration, login, JWT, email/OTP verification, profile pic), plus ancillary modules (notes, todo, resume builder, websearch, livebot).
- It exposes HTTP endpoints (in src/routes/*.py), orchestrates business logic in src/Chatbot, src/Intelli_News, src/profile, and persists data via src/database.py.

##### File structure
- Top-level:
– main.py: application entrypoint (starts web server, loads logger.py, database connection, mounts routers)
– logger.py: centralized logging configuration
– requirements.txt: Python dependencies (e.g., FastAPI, SQLAlchemy, external API SDKs)
- src/routes: groups HTTP route definitions by domain (auth, chat, news, profile, notes, todo, resume, websearch, livebot)
- src/Chatbot & src/Intelli_News: domain services implementing core AI logic (LLM prompts, chat definitions, news-fetching functions)
- src/profile: sub-modules for user management (email_service, otp, password hashing, JWT tokens, profile_pic uploads)
- src/database.py: handles database session setup and ORM models or raw queries

##### README
- README is empty—architecture hints come purely from code layout and naming.

a. Main components:
1. API Layer (main.py + route modules)
2. Business Logic Layer (Chatbot, Intelli_News, profile, notes, todo, resume, websearch, livebot modules)
3. Data Layer (database)
4. Infrastructure / External Services (SMTP/email provider, LLM service, News API, Web Search API, Cloud Storage for profile pics)
b. Relationships & interactions:
- Incoming HTTP Request → API Layer Route → invokes Business Logic → interacts with Database or External Service → returns HTTP Response
- Business Logic modules may call each other (e.g., profile module invoked by auth route)
c. Architectural patterns & design principles:
- Layered architecture: clear separation of API, domain logic, and data persistence
- Single monolith vs. microservices: although modularized, everything runs in one process
- Dependency inversion: route handlers depend on domain interfaces (e.g., Chatbot.prompt) rather than concrete HTTP code
d. Technologies, frameworks & libraries:
- FastAPI or Flask (web framework)
- SQLAlchemy or another ORM for database.py
- JWT library for token_jwt.py
- SMTP/SendGrid for email_service
- External LLM SDK (OpenAI, etc.) for Chatbot
- NewsAPI or custom HTTP client for Intelli_News
- File storage or S3 for profile_pic

##### Elements
– Rectangles for internal components: main.py, auth route, chat route, Chatbot module, etc.
- Blue for API components
- Green for business logic modules
- Orange for database
- Gray for external services

- main.py (entrypoint)
5. On the far right, place clouds for:
- LLM Provider (Chatbot)
- News API (Intelli_News)
- SMTP/Email provider (profile.email_service)
- Web Search API (websearch)
- Object Storage (profile_pic)
- Client → HTTP → Routes → Service modules
- Service modules → Database or External Cloud Services → back to Routes → Client

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Client"
        C["Client (Browser/Postman)"]:::client
    end

    subgraph "API Server"
        direction TB
        Main["main.py"]:::api
        Logger["logger.py"]:::api
        subgraph "Routes"
            direction TB
            Auth["auth.py"]:::api
            Chat["chat.py"]:::api
            News["news.py"]:::api
            ProfileRoute["profile.py"]:::api
            NotesRoute["notes.py"]:::api
            TodoRoute["todo.py"]:::api
            ResumeRoute["resume.py"]:::api
            WebsearchRoute["websearch.py"]:::api
            LivebotRoute["livebot.py"]:::api
        end
    end

    subgraph "Service Layer"
        direction TB
        ChatDef["chat_def.py"]:::service
        Prompt["prompt.py"]:::service
        IntelliNews["intelli_news_function.py"]:::service
        subgraph "Profile Service"
            Email["email_service.py"]:::service
            OTP["otp.py"]:::service
            Password["password.py"]:::service
            JWT["token_jwt.py"]:::service
            Form["form.py"]:::service
            ProfilePic["profile_pic.py"]:::service
        end
    end

    Data["Database"]:::db

    subgraph "External Services"
        direction TB
        LLM["LLM Provider"]:::external
        NewsAPI["News API"]:::external
        SMTP["SMTP/Email Provider"]:::external
        SearchAPI["Web Search API"]:::external
        Storage["Object Storage"]:::external
    end

    %% Connections
    C -->|"HTTP Request"| Main
    Main --> Auth
    Main --> Chat
    Main --> News
    Main --> ProfileRoute
    Main --> NotesRoute
    Main --> TodoRoute
    Main --> ResumeRoute
    Main --> WebsearchRoute
    Main --> LivebotRoute

    Auth -->|"calls Service"| Email
    Auth --> OTP
    Auth --> Password
    Auth --> JWT

    Chat --> ChatDef
    Chat --> Prompt
    ChatDef -->|"SDK Calls"| LLM
    Prompt -->|"SDK Calls"| LLM

    News --> IntelliNews
    IntelliNews -->|"REST API"| NewsAPI

    ProfileRoute --> Form
    ProfileRoute --> ProfilePic
    ProfilePic -->|"Storage SDK"| Storage

    NotesRoute --> Data
    TodoRoute --> Data
    ResumeRoute --> Data
    WebsearchRoute -->|"REST API"| SearchAPI
    LivebotRoute --> ChatDef

    Email -->|"SMTP"| SMTP

    Email --> Data
    OTP --> Data
    Password --> Data
    JWT --> Data
    Form --> Data
    ProfilePic --> Data

    ChatDef --> Data
    Prompt --> Data
    IntelliNews --> Data

    %% Responses
    Main -->|"HTTP Response"| C

    %% Click Events
    click Main "https://github.com/adeebmirza/intellihelper-backend/blob/main/main.py"
    click Logger "https://github.com/adeebmirza/intellihelper-backend/blob/main/logger.py"
    click Auth "https://github.com/adeebmirza/intellihelper-backend/blob/main/src/routes/auth.py"
    click Chat "https://github.com/adeebmirza/intellihelper-backend/blob/main/src/routes/chat.py"
    click News "https://github.com/adeebmirza/intellihelper-backend/blob/main/src/routes/news.py"
    click ProfileRoute "https://github.com/adeebmirza/intellihelper-backend/blob/main/src/routes/profile.py"
    click NotesRoute "https://github.com/adeebmirza/intellihelper-backend/blob/main/src/routes/notes.py"
    click TodoRoute "https://github.com/adeebmirza/intellihelper-backend/blob/main/src/routes/todo.py"
    click ResumeRoute "https://github.com/adeebmirza/intellihelper-backend/blob/main/src/routes/resume.py"
    click WebsearchRoute "https://github.com/adeebmirza/intellihelper-backend/blob/main/src/routes/websearch.py"
    click LivebotRoute "https://github.com/adeebmirza/intellihelper-backend/blob/main/src/routes/livebot.py"
    click ChatDef "https://github.com/adeebmirza/intellihelper-backend/blob/main/src/Chatbot/chat_def.py"
    click Prompt "https://github.com/adeebmirza/intellihelper-backend/blob/main/src/Chatbot/prompt.py"
    click IntelliNews "https://github.com/adeebmirza/intellihelper-backend/blob/main/src/Intelli_News/intelli_news_function.py"
    click Email "https://github.com/adeebmirza/intellihelper-backend/blob/main/src/profile/email_service.py"
    click OTP "https://github.com/adeebmirza/intellihelper-backend/blob/main/src/profile/otp.py"
    click Password "https://github.com/adeebmirza/intellihelper-backend/blob/main/src/profile/password.py"
    click JWT "https://github.com/adeebmirza/intellihelper-backend/blob/main/src/profile/token_jwt.py"
    click Form "https://github.com/adeebmirza/intellihelper-backend/blob/main/src/profile/form.py"
    click ProfilePic "https://github.com/adeebmirza/intellihelper-backend/blob/main/src/profile/profile_pic.py"
    click Data "https://github.com/adeebmirza/intellihelper-backend/blob/main/src/database.py"

    %% Styles
    classDef api fill:#cfe2f3,stroke:#2a7ab8,color:#000;
    classDef service fill:#d5ead1,stroke:#3c763d,color:#000;
    classDef db fill:#fce5cd,stroke:#a65f00,color:#000;
    classDef external fill:#e7e6e6,stroke:#666,color:#000;
    classDef client fill:#f2f2f2,stroke:#999,color:#000;
```
