# juan-npablo/inventariotest architecture

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

- Interactive diagram: https://gitdiagram.com/juan-npablo/inventariotest
- Repository: https://github.com/juan-npablo/inventariotest

## Overview

##### Project type and purpose
- From the file tree and minimal README, this appears to be a backend-only RESTful inventory service (likely built with FastAPI + SQLAlchemy + Alembic).
- It manages Users, Categories, Products, and Movements, with authentication and database migrations.

##### File structure
Top-level:
- app/main.py – application entry point (starts FastAPI server)
- app/api/v1 – route definitions (auth.py, categories.py, movements.py, products.py)
- app/core – configuration (config.py) and security utilities (security.py, e.g. JWT)
- app/db – database layer:
◦ base.py, base_class.py – common ORM base
◦ session.py – session/factory setup
◦ models/ – SQLAlchemy models
◦ schemas/ – Pydantic schemas for request/response
- app/services – business logic for each domain (user_service, category_service, etc.)
- app/alembic – migrations (ini, env.py, versions/*)
- app/tests – unit tests for permissions and roles

##### README
- The README only gives the project name (“InventarioTest”). No further architectural guidance is provided there.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client
    Client["Client (Web/Mobile)"]:::client

    %% API Layer
    subgraph "API Layer" 
        direction TB
        Auth["auth.py"]:::api
        Categories["categories.py"]:::api
        Movements["movements.py"]:::api
        Products["products.py"]:::api
    end

    %% Core Layer
    subgraph "Core Layer" 
        direction TB
        Config["config.py"]:::core
        Security["security.py"]:::core
    end

    %% Service Layer
    subgraph "Service Layer"
        direction TB
        UserService["user_service.py"]:::service
        CategoryService["category_service.py"]:::service
        ProductService["product_service.py"]:::service
        MovementService["movement_service.py"]:::service
    end

    %% Data Access Layer
    subgraph "Data Access Layer"
        direction TB
        Base["base.py"]:::data
        BaseClass["base_class.py"]:::data
        Session["session.py"]:::data
        subgraph "Models"
            direction TB
            UserModel["user.py"]:::data
            CategoryModel["category.py"]:::data
            ProductModel["product.py"]:::data
            MovementModel["movement.py"]:::data
        end
        subgraph "Schemas"
            direction TB
            UserSchema["user.py"]:::data
            CategorySchema["category.py"]:::data
            ProductSchema["product.py"]:::data
            MovementSchema["movement.py"]:::data
        end
    end

    %% Database
    DB["Database<br/>(PostgreSQL)"]:::db

    %% Migrations
    subgraph "Alembic Migrations"
        direction TB
        AlembicIni["alembic.ini"]:::migrations
        Env["env.py"]:::migrations
        ScriptMako["script.py.mako"]:::migrations
        Versions["versions/*.py"]:::migrations
    end

    %% Tests
    Tests["app/tests"]:::tests

    %% Application Entry
    Main["main.py"]:::entry

    %% Relationships
    Client -->|HTTP Request| Auth
    Client -->|HTTP Request| Categories
    Client -->|HTTP Request| Movements
    Client -->|HTTP Request| Products
    Auth -->|depends on| Security
    Categories -->|depends on| Security
    Movements -->|depends on| Security
    Products -->|depends on| Security

    Auth -->|calls| UserService
    Categories -->|calls| CategoryService
    Products -->|calls| ProductService
    Movements -->|calls| MovementService

    Auth -->|uses schemas| UserSchema
    Categories -->|uses schemas| CategorySchema
    Products -->|uses schemas| ProductSchema
    Movements -->|uses schemas| MovementSchema

    UserService -->|opens session| Session
    CategoryService -->|opens session| Session
    ProductService -->|opens session| Session
    MovementService -->|opens session| Session

    Session -->|manages| Base
    Session -->|manages| BaseClass
    Session -->|executes queries on| UserModel
    Session -->|executes queries on| CategoryModel
    Session -->|executes queries on| ProductModel
    Session -->|executes queries on| MovementModel

    UserModel -->|CRUD on| DB
    CategoryModel -->|CRUD on| DB
    ProductModel -->|CRUD on| DB
    MovementModel -->|CRUD on| DB

    AlembicIni -->|configures| Env
    Env -->|generates| Versions
    Env -->|uses template| ScriptMako
    Versions -->|migrates schema in| DB

    Main -->|starts| Auth
    Main -->|starts| Categories
    Main -->|starts| Products
    Main -->|starts| Movements

    Tests -->|tests| Auth
    Tests -->|tests| Categories
    Tests -->|tests| Movements
    Tests -->|tests| Products

    %% Click Events
    click Auth "https://github.com/juan-npablo/inventariotest/blob/main/app/api/v1/auth.py"
    click Categories "https://github.com/juan-npablo/inventariotest/blob/main/app/api/v1/categories.py"
    click Movements "https://github.com/juan-npablo/inventariotest/blob/main/app/api/v1/movements.py"
    click Products "https://github.com/juan-npablo/inventariotest/blob/main/app/api/v1/products.py"
    click Config "https://github.com/juan-npablo/inventariotest/blob/main/app/core/config.py"
    click Security "https://github.com/juan-npablo/inventariotest/blob/main/app/core/security.py"
    click UserService "https://github.com/juan-npablo/inventariotest/blob/main/app/services/user_service.py"
    click CategoryService "https://github.com/juan-npablo/inventariotest/blob/main/app/services/category_service.py"
    click ProductService "https://github.com/juan-npablo/inventariotest/blob/main/app/services/product_service.py"
    click MovementService "https://github.com/juan-npablo/inventariotest/blob/main/app/services/movement_service.py"
    click Base "https://github.com/juan-npablo/inventariotest/blob/main/app/db/base.py"
    click BaseClass "https://github.com/juan-npablo/inventariotest/blob/main/app/db/base_class.py"
    click Session "https://github.com/juan-npablo/inventariotest/blob/main/app/db/session.py"
    click UserModel "https://github.com/juan-npablo/inventariotest/blob/main/app/db/models/user.py"
    click CategoryModel "https://github.com/juan-npablo/inventariotest/blob/main/app/db/models/category.py"
    click ProductModel "https://github.com/juan-npablo/inventariotest/blob/main/app/db/models/product.py"
    click MovementModel "https://github.com/juan-npablo/inventariotest/blob/main/app/db/models/movement.py"
    click UserSchema "https://github.com/juan-npablo/inventariotest/blob/main/app/db/schemas/user.py"
    click CategorySchema "https://github.com/juan-npablo/inventariotest/blob/main/app/db/schemas/category.py"
    click ProductSchema "https://github.com/juan-npablo/inventariotest/blob/main/app/db/schemas/product.py"
    click MovementSchema "https://github.com/juan-npablo/inventariotest/blob/main/app/db/schemas/movement.py"
    click Main "https://github.com/juan-npablo/inventariotest/blob/main/app/main.py"
    click AlembicIni "https://github.com/juan-npablo/inventariotest/blob/main/app/alembic.ini"
    click Env "https://github.com/juan-npablo/inventariotest/blob/main/app/alembic/env.py"
    click ScriptMako "https://github.com/juan-npablo/inventariotest/blob/main/app/alembic/script.py.mako"
    click Versions "https://github.com/juan-npablo/inventariotest/tree/main/app/alembic/versions"
    click Tests "https://github.com/juan-npablo/inventariotest/tree/main/app/tests"

    %% Styles
    classDef client fill:#f9f,stroke:#333,stroke-width:1px;
    classDef api fill:#bbdefb,stroke:#0d47a1,stroke-width:1px;
    classDef core fill:#cfd8dc,stroke:#37474f,stroke-width:1px;
    classDef service fill:#c8e6c9,stroke:#2e7d32,stroke-width:1px;
    classDef data fill:#ffe0b2,stroke:#e65100,stroke-width:1px;
    classDef db fill:#b2dfdb,stroke:#004d40,stroke-width:1px,stroke-dasharray: 5 5;
    classDef migrations fill:#eceff1,stroke:#607d8b,stroke-width:1px,stroke-dasharray: 2 2;
    classDef tests fill:#e1bee7,stroke:#6a1b9a,stroke-width:1px,stroke-dasharray: 2 2;
    classDef entry fill:#fff9c4,stroke:#f57f17,stroke-width:1px;
```
