# tech0-swat/linkfastapinext_practical architecture

> Architecture diagram of the GitHub repository tech0-swat/linkfastapinext_practical, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-11-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tech0-swat/linkfastapinext_practical
- Repository: https://github.com/tech0-swat/linkfastapinext_practical

## Overview

##### Project type and purpose
- This is a full-stack CRUD application built with a FastAPI backend and a Next.js/React frontend.
- Purpose: manage “customers” (create, read, update, delete) via a web UI that communicates with a REST API.

##### File structure
- Top-level:
- backend/ – Python FastAPI service + db_control module (CRUD, models, SQLite/MySQL adapters).
- frontend/ – Next.js 13 app directory with React components under src/app, plus config files (package.json, tsconfig/jsconfig, tailwind.config).
- Patterns:
- Frontend follows Next.js file-based routing (pages under customers/create, customers/read/[id], etc.).
- Backend uses a layered approach: app.py (FastAPI endpoints) → db_control/connect, create_tables, crud, mymodels → database (CRM.db or MySQL).
- Deployment configs: uvicorn for backend; npm run dev for frontend.

##### README for additional insights
- Confirms two stand-alone services:
- backend: virtualenv, pip install, uvicorn app:app --reload
- frontend: npm install, npm run dev
- Base URL: http://localhost:3000/customers

##### Detail
- Optional MySQL adapter path vs. default SQLite path.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Browser Layer
    subgraph "Browser (React UI)" 
        direction TB
        Page["page.jsx"]:::frontend
        Card["one_customer_info_card.jsx"]:::frontend
        Edit["one_customer_info_edit.jsx"]:::frontend
        CustDir["customers/"]:::frontend
    end

    %% Frontend Next.js Server Layer
    subgraph "Next.js Server" 
        direction TB
        Package["package.json"]:::frontend
        NextConfig["next.config.js"]:::frontend
        JSConfig["jsconfig.json"]:::frontend
        AppRouter["src/app/"]:::frontend
    end

    %% Backend FastAPI Layer
    subgraph "FastAPI Service" 
        direction TB
        AppPY["app.py"]:::backend
        Requirements["requirements.txt"]:::backend
    end

    %% Database Layer
    subgraph "Database Layer" 
        direction TB

        subgraph "SQLite Adapter" 
            direction TB
            ConnectPY["connect.py"]:::backend
            CreateTables["create_tables.py"]:::backend
            Models["mymodels.py"]:::backend
            CRUD["crud.py"]:::backend
            CRMDB[(CRM.db)]:::database
        end

        subgraph "MySQL Adapter (optional)" 
            direction TB
            ConnectMySQL["connect_MySQL.py"]:::backend
            CreateTablesMySQL["create_tables_MySQL.py"]:::backend
            ModelsMySQL["mymodels_MySQL.py"]:::backend
        end
    end

    %% Connections
    Page -->|"renders UI & fetches"| NextConfig
    Card --> NextConfig
    Edit --> NextConfig
    CustDir --> NextConfig

    NextConfig -->|"routes & proxies API"| AppPY
    AppPY -->|"CRUD operations"| ConnectPY
    AppPY --> ConnectMySQL

    ConnectPY --> CRMDB
    ConnectMySQL --> ModelsMySQL
    CRUD --> CRMDB

    %% Click Events
    click Page "https://github.com/tech0-swat/linkfastapinext_practical/blob/main/frontend/src/app/page.jsx"
    click Card "https://github.com/tech0-swat/linkfastapinext_practical/blob/main/frontend/src/app/components/one_customer_info_card.jsx"
    click Edit "https://github.com/tech0-swat/linkfastapinext_practical/blob/main/frontend/src/app/components/one_customer_info_edit.jsx"
    click CustDir "https://github.com/tech0-swat/linkfastapinext_practical/tree/main/frontend/src/app/customers/"
    click Package "https://github.com/tech0-swat/linkfastapinext_practical/blob/main/frontend/package.json"
    click NextConfig "https://github.com/tech0-swat/linkfastapinext_practical/blob/main/frontend/next.config.js"
    click JSConfig "https://github.com/tech0-swat/linkfastapinext_practical/blob/main/frontend/jsconfig.json"
    click AppRouter "https://github.com/tech0-swat/linkfastapinext_practical/tree/main/frontend/src/app/"
    click AppPY "https://github.com/tech0-swat/linkfastapinext_practical/blob/main/backend/app.py"
    click Requirements "https://github.com/tech0-swat/linkfastapinext_practical/blob/main/backend/requirements.txt"
    click ConnectPY "https://github.com/tech0-swat/linkfastapinext_practical/blob/main/backend/db_control/connect.py"
    click CreateTables "https://github.com/tech0-swat/linkfastapinext_practical/blob/main/backend/db_control/create_tables.py"
    click Models "https://github.com/tech0-swat/linkfastapinext_practical/blob/main/backend/db_control/mymodels.py"
    click CRUD "https://github.com/tech0-swat/linkfastapinext_practical/blob/main/backend/db_control/crud.py"
    click CRMDB "https://github.com/tech0-swat/linkfastapinext_practical/blob/main/backend/db_control/CRM.db"
    click ConnectMySQL "https://github.com/tech0-swat/linkfastapinext_practical/blob/main/backend/db_control/connect_MySQL.py"
    click CreateTablesMySQL "https://github.com/tech0-swat/linkfastapinext_practical/blob/main/backend/db_control/create_tables_MySQL.py"
    click ModelsMySQL "https://github.com/tech0-swat/linkfastapinext_practical/blob/main/backend/db_control/mymodels_MySQL.py"

    %% Styles
    classDef frontend fill:#D6E4F0,stroke:#1E3A8A,stroke-width:1px
    classDef backend fill:#E2F0D9,stroke:#14532D,stroke-width:1px
    classDef database fill:#FCE8B2,stroke:#92400E,stroke-width:1px
```
