Skip to content

Arquitectura

Miguel-Marin-M edited this page Jul 5, 2026 · 2 revisions

Arquitectura del Código

Estructura de carpetas

Frontend (sommet-web/frontend)

frontend/
├── public/                  # Static files
├── src/
│   ├── app/                 # Next.js App Router
│   │   ├── (auth)/          # Authentication routes
│   │   │   ├── login/
│   │   │   └── register/
│   │   ├── (shop)/          # Public store routes
│   │   │   ├── page.tsx     # Home — catalog
│   │   │   ├── products/
│   │   │   │   └── [id]/    # Product detail
│   │   │   └── cart/
│   │   ├── orders/          # Order history (authenticated)
│   │   ├── admin/           # Admin panel
│   │   │   ├── products/
│   │   │   └── orders/
│   │   └── layout.tsx       # Root layout
│   ├── components/          # Reusable components
│   │   ├── ui/              # Base components (buttons, inputs)
│   │   ├── products/        # Catalog components
│   │   ├── cart/            # Cart components
│   │   └── admin/           # Admin panel components
│   ├── lib/                 # Utilities and configuration
│   │   ├── api.ts           # HTTP client for backend calls
│   │   └── auth.ts          # Auth.js configuration
│   ├── hooks/               # Custom React hooks
│   ├── types/               # Shared TypeScript types
│   └── styles/              # Global styles
├── .env.local               # Environment variables (not uploaded to repo)
├── .env.example             # Environment variables template
├── next.config.ts
├── tailwind.config.ts
└── tsconfig.json

Backend (sommet-web/backend)

backend/
├── src/
│   ├── routes/              # API route definitions
│   │   ├── products.ts
│   │   ├── orders.ts
│   │   ├── users.ts
│   │   └── auth.ts
│   ├── controllers/         # Endpoint logic
│   │   ├── products.controller.ts
│   │   ├── orders.controller.ts
│   │   ├── users.controller.ts
│   │   └── auth.controller.ts
│   ├── middlewares/         # Middlewares (auth, errors)
│   │   ├── auth.middleware.ts
│   │   └── error.middleware.ts
│   ├── services/            # Business logic
│   │   ├── products.service.ts
│   │   ├── orders.service.ts
│   │   └── auth.service.ts
│   ├── prisma/              # Configuration and migrations
│   │   └── schema.prisma
│   └── index.ts             # Entry point
├── .env                     # Environment variables (not uploaded to repo)
├── .env.example             # Environment variables template
├── package.json
└── tsconfig.json

Naming conventions

  • Files and folders: kebab-case → product-detail.tsx
  • React components: PascalCase → ProductDetail
  • Functions and variables: camelCase → getProducts
  • Types and interfaces: PascalCase → ProductWithSizes
  • Constants: UPPER_SNAKE_CASE → MAX_PRODUCT_IMAGES

Commits — Conventional Commits

feat: add size filter in catalog
fix: correct total calculation in cart
chore: update dependencies
docs: add endpoint documentation
refactor: extract order logic to service

Branches — Gitflow

main          → production code
develop       → feature integration
feature/*     → feature development
hotfix/*      → urgent production fixes

Examples:

feature/hu-01-product-catalog
feature/hu-04-user-register
hotfix/fix-stock-discount

REST API Design

Conventions

  • Routes in kebab-case and plural → /api/products
  • Version in route → /api/v1/
  • Responses always in JSON
  • Standard HTTP codes: 200, 201, 400, 401, 403, 404, 500

MVP Endpoints

Products

Method Route Description Access
GET /api/v1/products List products Public
GET /api/v1/products/:id Product detail Public
POST /api/v1/products Create product Admin
PUT /api/v1/products/:id Edit product Admin
DELETE /api/v1/products/:id Delete product Admin

Authentication

Method Route Description Access
POST /api/v1/auth/register Register client Public
POST /api/v1/auth/login Login Public
POST /api/v1/auth/logout Logout Authenticated

Orders

Method Route Description Access
GET /api/v1/orders List all orders Admin
GET /api/v1/orders/my-orders Client orders Authenticated
GET /api/v1/orders/:id Order detail Authenticated
POST /api/v1/orders Create order Authenticated
PATCH /api/v1/orders/:id/status Update status Admin

Clone this wiki locally