How juanospina0409/prueba-tecnica-lite-thinkng works
1. Purpose and deployable entry points
DataSoft Inventory is a multi-service enterprise inventory system: a Next.js UI, Django REST system of record, FastAPI utility service, and reusable Python domain package. Main runtime entries are backend-django/manage.py, microservice-fastapi/main.py, and the page-router frontend under frontend-nextjs/src/pages/. PostgreSQL infrastructure is orchestrated by docker-compose.yml.
2. Domain boundary
The domain package isolates business concepts and role validation from HTTP and ORM concerns. It defines Pydantic-oriented Empresa, Producto, and Usuario entities plus authorization rules, intended for reuse by adapters rather than direct persistence.
• domain-package/domain/entities.py
• domain-package/domain/rules.py
• domain-package/pyproject.toml
3. Django system of record
Django owns token authentication, custom users, company/product CRUD, role-based access, and PostgreSQL persistence. Project settings and route composition form the API boundary; the inventory app maps database models to serializers and REST views. The stated API surface is /api/auth/*, /api/empresas/*, and /api/productos/*.
• backend-django/core/settings.py
• backend-django/core/urls.py
• backend-django/inventario/models.py
• backend-django/inventario/views.py
• backend-django/inventario/urls.py
4. Inventory API flow and authorization
Requests enter Django URL routing, then inventory views apply authentication/role policy, serialize request and model data, and persist to PostgreSQL. Administrators have CRUD authority; external users are read-only. The custom user model is architecturally important because it must be migrated before general database migration.
• backend-django/inventario/views.py
• backend-django/inventario/serializers.py
• backend-django/inventario/migrations/0001_initial.py
• backend-django/core/settings.py
5. FastAPI auxiliary-service boundary
FastAPI is independently runnable and exposes report generation, email delivery, AI copy suggestions, and a SHA-256-backed audit ledger. It is a service boundary separate from Django persistence/auth: clients invoke it over HTTP, and it integrates outward with ReportLab, Brevo REST email, and Google Gemini. Its blockchain ledger is described as simplified rather than durable database-backed.
• microservice-fastapi/main.py
• microservice-fastapi/Dockerfile
• microservice-fastapi/requirements.txt
6. Frontend interaction layer
The Next.js Pages Router provides login, company/product administration, inventory reporting, and AI copilot screens. Shared layout/navigation wraps these screens. Browser-side configuration selects Django and FastAPI base URLs, so the frontend calls both backend boundaries directly.
• frontend-nextjs/src/pages/_app.js
• frontend-nextjs/src/pages/login.js
• frontend-nextjs/src/pages/inventario.js
• frontend-nextjs/src/pages/copiloto.js
• frontend-nextjs/src/components/Layout.js
7. Runtime infrastructure and configuration
PostgreSQL 16 with pgvector is the central durable store, launched through Docker Compose. A root environment file supplies database credentials and external API keys across Docker, Django, and FastAPI; production separates hosting concerns between Render services and Vercel frontend. Django and FastAPI each have container definitions, while local development runs them separately on ports 8000 and 8001, with Next.js on 3000.
• docker-compose.yml
• .env.example
• backend-django/Dockerfile
• microservice-fastapi/Dockerfile
• frontend-nextjs/next.config.js
Main entry points: main.py FastAPI service · views.py Inventory views · models.py Inventory models · docker-compose.yml Docker Compose
Components 17
Frontend
- Next.js Pages Router · Login, inventory administration, reporting, and copilot screens.
- Shared layout
frontend-nextjs/src/components/Layout.js
Django system of record
- Django API routes · Composes auth, company, and product API routes.
backend-django/core/urls.py - Inventory views · Applies authentication and role policy for inventory operations.
backend-django/inventario/views.py - Inventory serializers
backend-django/inventario/serializers.py - Inventory models · Company, product, and custom user persistence mapping.
backend-django/inventario/models.py - Django settings · Configures authentication and the custom user model.
backend-django/core/settings.py
FastAPI auxiliary service
- FastAPI service · Provides reports, email delivery, AI suggestions, and audit ledger.
microservice-fastapi/main.py - SHA-256 audit ledger · Simplified ledger without durable database backing.
microservice-fastapi/main.py - Report, email, and AI providers · ReportLab, Brevo, and Google Gemini integrations.
microservice-fastapi/main.py
Platform
- PostgreSQL 16 + pgvector · Central database for Django system-of-record data.
docker-compose.yml - Docker Compose · Launches PostgreSQL and containerized services.
docker-compose.yml - Shared environment · Supplies database credentials and external API keys.
.env.example - Django container
backend-django/Dockerfile - FastAPI container
microservice-fastapi/Dockerfile
Other components
- Domain entities · Reusable Pydantic-oriented Empresa, Producto, and Usuario concepts.
domain-package/domain/entities.py - Authorization rules
domain-package/domain/rules.py
Connections 21
- Next.js Pages Router → Shared layout: wraps screens
- Next.js Pages Router → Django API routes: calls REST API
- Next.js Pages Router → FastAPI service: calls utility API
- Django API routes → Inventory views: routes requests
- Inventory views → Inventory serializers: serializes payloads
- Inventory views → Inventory models: reads and writes
- Inventory views → Authorization rules: enforces roles
- Inventory serializers → Inventory models: maps API data
- Inventory models → PostgreSQL 16 + pgvector: persists
- Django settings → Inventory models: selects custom user model
- Authorization rules → Domain entities: validates roles for
- FastAPI service → SHA-256 audit ledger: records audits
- FastAPI service → Report, email, and AI providers: generates and delivers
- Docker Compose → PostgreSQL 16 + pgvector: starts
- Docker Compose → Django container: orchestrates
- Docker Compose → FastAPI container: orchestrates
- Django container → Django API routes: runs
- FastAPI container → FastAPI service: runs
- Shared environment → PostgreSQL 16 + pgvector: configures credentials
- Shared environment → Django settings: supplies settings
- Shared environment → FastAPI service: supplies API keys