# 2025-meichuhackathon-team-yee-da-tuo/backend architecture

> Architecture diagram of the GitHub repository 2025-meichuhackathon-team-yee-da-tuo/backend, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-09-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/2025-meichuhackathon-team-yee-da-tuo/backend
- Repository: https://github.com/2025-meichuhackathon-team-yee-da-tuo/backend

## Overview

##### Project type and purpose
- This is a backend-only RESTful API service (no frontend code in the repo).
- Its primary responsibility is user management (register/login), trades, and fuzzy search over some dataset.
- It exposes HTTP endpoints under `/api/*`.

##### File structure
- Top level:
- `main.py` – application entrypoint.
- `api/` – routing layer: `auth.py`, `trade.py`, `fuzzy_search.py`.
- `core/` – business‐logic utilities: `db.py` (database session), `graph_manager.py`.
- `models/` – data definitions: `user_model.py`, `user_schema.py`.
- `requirements.txt` – third‐party dependencies.
- No separate frontend; MVC‐style separation:
View = API endpoints,
Controller/Service = core/graph_manager & db,
Model = models/.

##### README for additional insights
- Describes two endpoints: user registration and login.
- Base URL `http://127.0.0.1:8000`.
- While only auth endpoints are documented, existence of `trade.py` and `fuzzy_search.py` implies further business features.

##### Detail
- Flow of data through Pydantic schemas into SQLAlchemy models.
- If `graph_manager.py` interfaces with a graph database or in‐memory graph, represent that as well.
- Don’t oversimplify: show each endpoint group, each core utility, and the DB.

1) Client
↓
2) main.py (ASGI entrypoint)
↓
3) API Layer
├─ Auth Module (`api/auth.py`)
├─ Trade Module (`api/trade.py`)
└─ Fuzzy Search Module (`api/fuzzy_search.py`)
↓
4) Business Logic Layer
├─ DB Session Manager (`core/db.py`)
└─ Graph Manager (`core/graph_manager.py`)
↓
5) Data Layer
├─ User Model & Schema (`models/`)
└─ Database (PostgreSQL or SQLite)
←– Responses flow back up the same path

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Client
    Client["Client"]:::external

    %% Entry Point
    Entrypoint["main.py (ASGI Entrypoint)"]:::entrypoint

    %% API Layer
    subgraph "API Layer"
        direction TB
        Auth["API Auth Module"]:::api
        Trade["API Trade Module"]:::api
        FuzzySearch["API Fuzzy Search Module"]:::api
    end

    %% Business Logic Layer
    subgraph "Business Logic Layer"
        direction TB
        DBManager["DB Session Manager"]:::business
        GraphManager["Graph Manager"]:::business
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        UserModel["User Model (ORM)"]:::data
        UserSchema["User Schema (Pydantic)"]:::data
        Database[(PostgreSQL Database)]:::database
    end

    %% Connections
    Client -->|"HTTP Request"| Entrypoint
    Entrypoint -->|"routes to"| Auth
    Entrypoint -->|"routes to"| Trade
    Entrypoint -->|"routes to"| FuzzySearch

    Auth -->|"validate & handle"| UserSchema
    Trade -->|"use models & logic"| UserModel
    FuzzySearch -->|"validate & handle"| UserSchema

    Auth -->|"calls"| DBManager
    Trade -->|"calls"| DBManager
    FuzzySearch -->|"calls"| DBManager
    Auth -->|"calls"| GraphManager

    DBManager -->|"reads/writes"| Database
    GraphManager -->|"optional graph operations"| Database

    UserModel -->|"defines schema"| Database
    UserSchema -->|"validates data"| Auth

    Database -->|"response data"| DBManager
    DBManager -->|"returns result"| Auth
    GraphManager -->|"returns result"| Auth
    Auth -->|"HTTP Response"| Client

    %% Click Events
    click main "https://github.com/2025-meichuhackathon-team-yee-da-tuo/backend/blob/main/main.py"
    click Auth "https://github.com/2025-meichuhackathon-team-yee-da-tuo/backend/blob/main/api/auth.py"
    click Trade "https://github.com/2025-meichuhackathon-team-yee-da-tuo/backend/blob/main/api/trade.py"
    click FuzzySearch "https://github.com/2025-meichuhackathon-team-yee-da-tuo/backend/blob/main/api/fuzzy_search.py"
    click DBManager "https://github.com/2025-meichuhackathon-team-yee-da-tuo/backend/blob/main/core/db.py"
    click GraphManager "https://github.com/2025-meichuhackathon-team-yee-da-tuo/backend/blob/main/core/graph_manager.py"
    click UserModel "https://github.com/2025-meichuhackathon-team-yee-da-tuo/backend/blob/main/models/user_model.py"
    click UserSchema "https://github.com/2025-meichuhackathon-team-yee-da-tuo/backend/blob/main/models/user_schema.py"
    click API_Pkg "https://github.com/2025-meichuhackathon-team-yee-da-tuo/backend/tree/main/api/"
    click Core_Pkg "https://github.com/2025-meichuhackathon-team-yee-da-tuo/backend/tree/main/core/"
    click Models_Pkg "https://github.com/2025-meichuhackathon-team-yee-da-tuo/backend/tree/main/models/"
    click Requirements "https://github.com/2025-meichuhackathon-team-yee-da-tuo/backend/blob/main/requirements.txt"

    %% Styles
    classDef external fill:#f9f,stroke:#333,stroke-width:2px;
    classDef entrypoint fill:#ffe599,stroke:#333,stroke-width:2px;
    classDef api fill:#9fc5e8,stroke:#333,stroke-width:2px;
    classDef business fill:#b6d7a8,stroke:#333,stroke-width:2px;
    classDef data fill:#ffe599,stroke:#333,stroke-width:2px;
    classDef database fill:#d9d2e9,stroke:#333,stroke-width:2px;
    class API_Pkg,Core_Pkg,Models_Pkg,Requirements invisible;
```
