# favoursui/scan_info_tech architecture

> Architecture diagram of the GitHub repository favoursui/scan_info_tech, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/favoursui/scan_info_tech
- Repository: https://github.com/favoursui/scan_info_tech

## Overview

#### Purpose and Runtime Topology
Scan Info Tech is a containerized product catalog, cart, ordering, and IT-services platform. A static Vanilla JS frontend calls a FastAPI REST API; the API persists operational data in MySQL and integrates Cloudinary for product images and Gmail SMTP for account email. Docker Compose orchestrates frontend Nginx, backend Gunicorn/Uvicorn, MySQL, and phpMyAdmin.
Paths: `docker-compose.yml`, `Dockerfile`, `nginx.conf`

#### Entry Points and Delivery
The backend application entry point is FastAPI initialization and router registration in `backend/app/main.py`, served through Gunicorn configuration in `backend/gunicorn.conf.py`. Container startup is mediated by `entrypoint.sh`, including automatic Alembic migration execution. The browser entry surface is prebuilt HTML under `frontend/build/`, served by Nginx.
Paths: `backend/app/main.py`, `entrypoint.sh`, `frontend/build/index.html`

#### API Layer and Request Boundaries
Route modules expose resource-oriented API boundaries for authentication, products, carts, orders, admin operations, inventory, and services. Routes validate/request-shape through schema modules and delegate domain work to service modules rather than directly defining application workflows.
Paths: `backend/app/routes/auth.py`, `backend/app/routes/orders.py`, `backend/app/routes/inventory.py`

#### Identity, Authorization, and Account Lifecycle
JWT plus bcrypt security supports registration, login, verified-email flow, password-reset OTPs, lockout behavior, suspension, and role-based administration. Dependency injection centralizes authentication and admin checks before protected cart, order, inventory, and admin operations. User state is persisted alongside account-related records.
Paths: `backend/app/core/security.py`, `backend/app/core/dependencies.py`, `backend/app/services/auth_service.py`

#### Commerce Domain Flow
Public consumers browse paginated products and details. Authenticated users add/update/clear cart items; checkout transforms cart activity into order/transaction records, while order history exposes user-scoped results. Admin paths read platform-wide users/orders/products and manage product inventory.
Paths: `backend/app/services/cart_service.py`, `backend/app/services/order_service.py`, `backend/app/models/order.py`

#### Persistence and Schema Evolution
SQLAlchemy models represent users, products, carts, orders, transactions, accounts, guests, and services against MySQL. Database session/engine setup is isolated from route logic. Alembic owns the evolving relational schema, with sequential migrations covering the initial model, suspension, lockout, verification, reset OTP, and services.
Paths: `backend/app/database.py`, `backend/app/models/product.py`, `backend/alembic/versions/0006_add_services.py`

#### Frontend Integration
The frontend is a static multi-page application, not a frontend runtime/server-rendered app. Shared API/auth client code and page-focused scripts manage browser interactions for login, products, cart, orders, admin, and services; the API/JWT boundary is in browser JavaScript.
Paths: `frontend/build/js/api.js`, `frontend/build/js/auth.js`, `frontend/build/js/cart.js`

#### External Service Boundaries
Inventory image create/update/delete operations cross into Cloudinary; account verification, resets, and lockout notifications cross into configured Gmail SMTP via fastapi-mail. Environment-driven credentials and connection strings are centralized in backend configuration and supplied through container environment.
Paths: `backend/app/utils/cloudinary.py`, `backend/app/utils/email.py`, `backend/app/config.py`

Main entry points: [`backend/app/routes/orders.py`](https://github.com/favoursui/scan_info_tech/blob/main/backend/app/routes/orders.py) (Route Boundaries), [`backend/app/database.py`](https://github.com/favoursui/scan_info_tech/blob/main/backend/app/database.py) (SQLAlchemy Database), [`backend/app/services/auth_service.py`](https://github.com/favoursui/scan_info_tech/blob/main/backend/app/services/auth_service.py) (Account Lifecycle), [`backend/app/config.py`](https://github.com/favoursui/scan_info_tech/blob/main/backend/app/config.py) (Backend Configuration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Container Runtime"]
  node_compose{{"Docker Compose<br/>orchestration<br/>[docker-compose.yml]"}}
  node_nginx["Nginx<br/>static server<br/>[nginx.conf]"]
  node_startup["Container Entrypoint<br/>startup script<br/>[entrypoint.sh]"]
end

subgraph group_frontend["Browser Frontend"]
  node_browser["Static Pages<br/>browser UI<br/>[index.html]"]
  node_frontend_api["API &amp; Auth Client<br/>browser client<br/>[api.js]"]
  node_frontend_cart["Cart UI<br/>page script<br/>[cart.js]"]
end

subgraph group_backend["FastAPI Backend"]
  node_api["FastAPI Application<br/>REST API<br/>[main.py]"]
  node_routes["Route Boundaries<br/>route modules<br/>[orders.py]"]
  node_access["JWT &amp; Access Checks<br/>security dependencies<br/>[dependencies.py]"]
  node_auth_service["Account Lifecycle<br/>domain service<br/>[auth_service.py]"]
  node_cart_service["Cart Service<br/>domain service<br/>[cart_service.py]"]
  node_order_service["Order Service<br/>domain service<br/>[order_service.py]"]
  node_config["Backend Configuration<br/>environment config<br/>[config.py]"]
end

subgraph group_data["Data &amp; Integrations"]
  node_database[("SQLAlchemy Database<br/>session and engine<br/>[database.py]")]
  node_models["Commerce Models<br/>SQLAlchemy models<br/>[product.py]"]
  node_migrations["Alembic Migrations<br/>schema evolution"]
  node_cloudinary(("Cloudinary<br/>image service<br/>[cloudinary.py]"))
  node_email(("Gmail SMTP<br/>email service<br/>[email.py]"))
end

node_compose -->|"runs"| node_nginx
node_compose -->|"starts backend"| node_startup
node_nginx -->|"serves"| node_browser
node_browser -->|"uses"| node_frontend_api
node_frontend_cart -->|"calls through"| node_frontend_api
node_frontend_api -->|"REST requests with JWT"| node_api
node_startup -->|"runs"| node_migrations
node_startup -->|"launches"| node_api
node_api -->|"registers"| node_routes
node_routes -->|"protects requests"| node_access
node_routes -->|"delegates account flows"| node_auth_service
node_routes -->|"delegates cart flows"| node_cart_service
node_routes -->|"delegates checkout and history"| node_order_service
node_access -->|"uses identity state"| node_auth_service
node_auth_service -->|"persists accounts"| node_database
node_cart_service -->|"persists carts"| node_database
node_order_service -->|"persists orders"| node_database
node_database -->|"maps"| node_models
node_migrations -->|"evolves schema"| node_database
node_routes -->|"inventory image operations"| node_cloudinary
node_auth_service -->|"account notifications"| node_email
node_config -.->|"connection settings"| node_database
node_config -.->|"credentials"| node_cloudinary
node_config -.->|"credentials"| node_email

click node_compose "https://github.com/favoursui/scan_info_tech/blob/main/docker-compose.yml"
click node_nginx "https://github.com/favoursui/scan_info_tech/blob/main/nginx.conf"
click node_startup "https://github.com/favoursui/scan_info_tech/blob/main/entrypoint.sh"
click node_browser "https://github.com/favoursui/scan_info_tech/blob/main/frontend/build/index.html"
click node_frontend_api "https://github.com/favoursui/scan_info_tech/blob/main/frontend/build/js/api.js"
click node_frontend_cart "https://github.com/favoursui/scan_info_tech/blob/main/frontend/build/js/cart.js"
click node_api "https://github.com/favoursui/scan_info_tech/blob/main/backend/app/main.py"
click node_routes "https://github.com/favoursui/scan_info_tech/blob/main/backend/app/routes/orders.py"
click node_access "https://github.com/favoursui/scan_info_tech/blob/main/backend/app/core/dependencies.py"
click node_auth_service "https://github.com/favoursui/scan_info_tech/blob/main/backend/app/services/auth_service.py"
click node_cart_service "https://github.com/favoursui/scan_info_tech/blob/main/backend/app/services/cart_service.py"
click node_order_service "https://github.com/favoursui/scan_info_tech/blob/main/backend/app/services/order_service.py"
click node_config "https://github.com/favoursui/scan_info_tech/blob/main/backend/app/config.py"
click node_database "https://github.com/favoursui/scan_info_tech/blob/main/backend/app/database.py"
click node_models "https://github.com/favoursui/scan_info_tech/blob/main/backend/app/models/product.py"
click node_migrations "https://github.com/favoursui/scan_info_tech/blob/main/backend/alembic/versions/0006_add_services.py"
click node_cloudinary "https://github.com/favoursui/scan_info_tech/blob/main/backend/app/utils/cloudinary.py"
click node_email "https://github.com/favoursui/scan_info_tech/blob/main/backend/app/utils/email.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_compose,node_nginx,node_startup toneBlue
class node_browser,node_frontend_api,node_frontend_cart toneAmber
class node_api,node_routes,node_access,node_auth_service,node_cart_service,node_order_service,node_config toneMint
class node_database,node_models,node_migrations,node_cloudinary,node_email toneRose
```

## Components

### Container Runtime

- [Docker Compose](https://github.com/favoursui/scan_info_tech/blob/main/docker-compose.yml): orchestration · Runs frontend, backend, MySQL, and phpMyAdmin containers. · `docker-compose.yml`
- [Nginx](https://github.com/favoursui/scan_info_tech/blob/main/nginx.conf): static server · `nginx.conf`
- [Container Entrypoint](https://github.com/favoursui/scan_info_tech/blob/main/entrypoint.sh): startup script · Runs migrations before starting the backend server. · `entrypoint.sh`

### Browser Frontend

- [Static Pages](https://github.com/favoursui/scan_info_tech/blob/main/frontend/build/index.html): browser UI · `frontend/build/index.html`
- [API & Auth Client](https://github.com/favoursui/scan_info_tech/blob/main/frontend/build/js/api.js): browser client · Carries API requests and JWT state in browser JavaScript. · `frontend/build/js/api.js`
- [Cart UI](https://github.com/favoursui/scan_info_tech/blob/main/frontend/build/js/cart.js): page script · `frontend/build/js/cart.js`

### FastAPI Backend

- [FastAPI Application](https://github.com/favoursui/scan_info_tech/blob/main/backend/app/main.py): REST API · Registers resource routers and serves backend API requests. · `backend/app/main.py`
- [Route Boundaries](https://github.com/favoursui/scan_info_tech/blob/main/backend/app/routes/orders.py): route modules · Authentication, orders, inventory, and other resource endpoints. · `backend/app/routes/orders.py`
- [JWT & Access Checks](https://github.com/favoursui/scan_info_tech/blob/main/backend/app/core/dependencies.py): security dependencies · Centralizes authentication and admin authorization for protected operations. · `backend/app/core/dependencies.py`
- [Account Lifecycle](https://github.com/favoursui/scan_info_tech/blob/main/backend/app/services/auth_service.py): domain service · Handles registration, login, verification, reset OTPs, lockouts, and suspension. · `backend/app/services/auth_service.py`
- [Cart Service](https://github.com/favoursui/scan_info_tech/blob/main/backend/app/services/cart_service.py): domain service · `backend/app/services/cart_service.py`
- [Order Service](https://github.com/favoursui/scan_info_tech/blob/main/backend/app/services/order_service.py): domain service · Converts checkout cart activity into orders and transactions. · `backend/app/services/order_service.py`
- [Backend Configuration](https://github.com/favoursui/scan_info_tech/blob/main/backend/app/config.py): environment config · Centralizes connection strings and external-service credentials. · `backend/app/config.py`

### Data & Integrations

- [SQLAlchemy Database](https://github.com/favoursui/scan_info_tech/blob/main/backend/app/database.py): session and engine · Isolates MySQL sessions and engine setup from route logic. · `backend/app/database.py`
- [Commerce Models](https://github.com/favoursui/scan_info_tech/blob/main/backend/app/models/product.py): SQLAlchemy models · Represents products, carts, orders, transactions, users, and related records. · `backend/app/models/product.py`
- [Alembic Migrations](https://github.com/favoursui/scan_info_tech/blob/main/backend/alembic/versions/0006_add_services.py): schema evolution · Maintains sequential relational schema changes. · `backend/alembic/versions/0006_add_services.py`
- [Cloudinary](https://github.com/favoursui/scan_info_tech/blob/main/backend/app/utils/cloudinary.py): image service · Stores product inventory images. · `backend/app/utils/cloudinary.py`
- [Gmail SMTP](https://github.com/favoursui/scan_info_tech/blob/main/backend/app/utils/email.py): email service · Sends account verification, reset, and lockout messages. · `backend/app/utils/email.py`

## Connections

- Docker Compose → Nginx: runs
- Docker Compose → Container Entrypoint: starts backend
- Nginx → Static Pages: serves
- Static Pages → API & Auth Client: uses
- Cart UI → API & Auth Client: calls through
- API & Auth Client → FastAPI Application: REST requests with JWT
- Container Entrypoint → Alembic Migrations: runs
- Container Entrypoint → FastAPI Application: launches
- FastAPI Application → Route Boundaries: registers
- Route Boundaries → JWT & Access Checks: protects requests
- Route Boundaries → Account Lifecycle: delegates account flows
- Route Boundaries → Cart Service: delegates cart flows
- Route Boundaries → Order Service: delegates checkout and history
- JWT & Access Checks → Account Lifecycle: uses identity state
- Account Lifecycle → SQLAlchemy Database: persists accounts
- Cart Service → SQLAlchemy Database: persists carts
- Order Service → SQLAlchemy Database: persists orders
- SQLAlchemy Database → Commerce Models: maps
- Alembic Migrations → SQLAlchemy Database: evolves schema
- Route Boundaries → Cloudinary: inventory image operations
- Account Lifecycle → Gmail SMTP: account notifications
- Backend Configuration → SQLAlchemy Database: connection settings
- Backend Configuration → Cloudinary: credentials
- Backend Configuration → Gmail SMTP: credentials
