Skip to content

RustamovAkrom/E-Commerce

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

9 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ›’ E-Commerce Platform

Zamonaviy e-commerce platforma β€” backend (FastAPI), frontend (Next.js) va Telegram bot dan iborat.

πŸ“‹ Content

πŸ— Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     HTTPS      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Browser   β”‚ ◄────────────► β”‚   Nginx      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                β”‚  (Frontend)  β”‚
                               β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
                                      β”‚ REST
                               β”Œβ”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”
                               β”‚   FastAPI    β”‚
                               β”‚  (Backend)   β”‚
                               β””β”€β”€β”¬β”€β”€β”€β”¬β”€β”€β”€β”¬β”€β”€β”˜
                                  β”‚   β”‚   β”‚
                        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚   └──────────┐
                        β”‚             β”‚              β”‚
                  β”Œβ”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”΄β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”
                  β”‚ PostgreSQLβ”‚  β”‚ Redis β”‚   β”‚   MinIO     β”‚
                  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ›  Tech Stack

Layer Technology
Frontend Next.js 14, React 19, TypeScript, Tailwind CSS v4
shadcn/ui, TanStack Query v5, Zustand
Backend FastAPI, Python 3.12, SQLAlchemy 2 (async)
PostgreSQL, Redis, MinIO (S3)
Bot Aiogram 3, httpx
Infra Docker, Docker Compose, Nginx

πŸš€ Quick Start

Prerequisites

One-command setup

# 1. Clone & setup
git clone <repo-url>
cd ecommerce-platform
cp .env.example .env          # edit .env for your needs
make install                  # install all dependencies
make dev                      # start all services via Docker

Services will be available at:

πŸ”§ Environment Setup

Copy and configure

cp .env.example .env
# Edit .env β€” at minimum set SECRET_KEY and BOT_TOKEN

Local development (without Docker)

# Backend
cd backend && uv sync && uv run uvicorn src.main:app --reload

# Frontend
cd frontend && pnpm install && pnpm dev

# Bot
cd bot && uv sync && uv run python -m bot.main

πŸ–₯ Backend

Project structure

backend/src/
β”œβ”€β”€ main.py                  # App factory
β”œβ”€β”€ config.py                # Settings (env-based)
β”œβ”€β”€ models_registry.py       # All ORM models
β”œβ”€β”€ models/                  # SQLAlchemy models
β”œβ”€β”€ modules/                 # Feature modules
β”‚   β”œβ”€β”€ auth/                # JWT auth (register, login, refresh)
β”‚   β”œβ”€β”€ users/               # User CRUD
β”‚   β”œβ”€β”€ catalog/             # Categories & Products
β”‚   β”œβ”€β”€ inventory/           # Stock management
β”‚   β”œβ”€β”€ cart/                # Redis-based cart
β”‚   β”œβ”€β”€ orders/              # Order lifecycle
β”‚   β”œβ”€β”€ payments/            # Click, Payme, Stripe
β”‚   β”œβ”€β”€ shipping/            # Shipping methods
β”‚   β”œβ”€β”€ reviews/             # Product reviews
β”‚   β”œβ”€β”€ vendors/             # Marketplace vendors
β”‚   β”œβ”€β”€ notifications/       # Email/SMS/Telegram
β”‚   β”œβ”€β”€ tasks/               # Celery background tasks
β”‚   └── admin/               # Admin dashboard API
β”œβ”€β”€ core/                    # Shared infrastructure
β”‚   β”œβ”€β”€ base_repository.py   # Generic CRUD repo
β”‚   β”œβ”€β”€ dependencies.py      # DI providers
β”‚   β”œβ”€β”€ exceptions.py        # App exceptions
β”‚   β”œβ”€β”€ middleware.py        # CORS, timing, etc.
β”‚   β”œβ”€β”€ pagination.py        # Page<T> pagination
β”‚   β”œβ”€β”€ rate_limit.py        # slowapi limiter
β”‚   β”œβ”€β”€ redis.py             # Redis client
β”‚   └── schemas.py           # Base Pydantic schemas
└── utils/                   # Helpers

Commands

cd backend

uv run uvicorn src.main:app --reload          # dev server
uv run alembic upgrade head                   # DB migrations
uv run alembic revision --autogenerate -m "msg"  # new migration
uv run pytest -v                              # tests
uv run ruff check . --fix                     # lint
uv run mypy src/                              # type check

API Endpoints (67 routes)

Prefix Method Description Auth
/api/v1/auth POST register, login, refresh Public
/api/v1/users GET/PATCH admin user management Admin
/api/v1/users/me GET/PATCH current user profile User
/api/v1/catalog GET categories, products Public
/api/v1/catalog POST/PATCH/DELETE product CRUD Admin
/api/v1/cart GET/POST/DELETE cart operations User
/api/v1/orders POST create from cart User
/api/v1/orders GET my orders User
/api/v1/orders/{id} GET/PATCH order detail + status Admin
/api/v1/payments POST init payment User
/api/v1/shipping GET available methods Public
/api/v1/admin GET dashboard stats Admin

Full interactive docs: http://localhost:8000/api/docs

🎨 Frontend

Project structure

frontend/src/
β”œβ”€β”€ app/                     # Next.js App Router
β”‚   β”œβ”€β”€ layout.tsx           # Root layout (providers, header, footer)
β”‚   β”œβ”€β”€ page.tsx             # Homepage (hero + featured products)
β”‚   β”œβ”€β”€ globals.css          # Design tokens + animations
β”‚   β”œβ”€β”€ (shop)/              # Public pages
β”‚   β”‚   β”œβ”€β”€ products/        # Product listing + detail
β”‚   β”œβ”€β”€ (auth)/              # Auth pages
β”‚   β”‚   β”œβ”€β”€ login/           # Login form
β”‚   β”‚   └── register/        # Register form
β”‚   β”œβ”€β”€ cart/                # Cart page
β”‚   β”œβ”€β”€ checkout/            # Multi-step checkout
β”‚   β”œβ”€β”€ account/             # User account
β”‚   β”‚   β”œβ”€β”€ orders/          # Order history
β”‚   β”‚   └── addresses/       # Address management
β”‚   β”œβ”€β”€ admin/               # Admin dashboard
β”‚   β”‚   β”œβ”€β”€ products/        # Product CRUD table
β”‚   β”‚   └── orders/          # Order management
β”‚   β”œβ”€β”€ success/             # Order confirmation
β”‚   └── api/                 # Next.js API routes (auth proxy)
β”œβ”€β”€ components/
β”‚   β”œβ”€β”€ layout/              # Header, Footer, Sidebar
β”‚   β”œβ”€β”€ product/             # ProductCard, Grid, Filters, Images
β”‚   β”œβ”€β”€ cart/                # CartDrawer, CartItem, Summary
β”‚   β”œβ”€β”€ common/              # LoadingSpinner, ErrorMessage, etc.
β”‚   β”œβ”€β”€ providers/           # QueryProvider, AuthProvider
β”‚   └── ui/                  # shadcn/ui primitives
β”œβ”€β”€ lib/
β”‚   β”œβ”€β”€ design-system.ts     # Color tokens, spacing, animations
β”‚   β”œβ”€β”€ config.ts            # App config
β”‚   β”œβ”€β”€ api/                 # Typed API modules
β”‚   β”‚   β”œβ”€β”€ client.ts        # Base fetch (401 refresh + retry)
β”‚   β”‚   β”œβ”€β”€ auth.ts          # login, register, logout
β”‚   β”‚   β”œβ”€β”€ products.ts      # list, detail, CRUD
β”‚   β”‚   β”œβ”€β”€ cart.ts          # get, add, remove, clear
β”‚   β”‚   β”œβ”€β”€ orders.ts        # create, list, detail
β”‚   β”‚   └── users.ts         # profile, update
β”‚   └── stores/              # Zustand stores
β”‚       β”œβ”€β”€ auth.store.ts    # user, tokens, login/logout
β”‚       └── cart.store.ts    # items, total, sync
└── types/
    └── api.ts               # All API TypeScript types

Commands

cd frontend

pnpm install                     # install deps
pnpm dev                         # dev server (localhost:3000)
pnpm build                       # production build
pnpm lint                        # ESLint
pnpm typecheck                   # TypeScript type check

Design System

All design tokens are in src/lib/design-system.ts:

  • Colors: primary, secondary, accent, surface, muted, border (HSL)
  • Spacing: xs(4px) β†’ 2xl(40px)
  • Border Radius: sm/md/lg/full
  • Shadows: sm/md/lg/xl
  • Animations: fade-in, slide-up, scale-in, shimmer, pulse-ring
  • Breakpoints: sm(640px) β†’ 2xl(1536px)

Animations (CSS-only, no Framer Motion)

Animation Duration Use Case
fade-in 300ms Page transitions
slide-up 400ms Page transitions
slide-in-right 350ms Toasts, Cart drawer
scale-in 200ms Modals, Dropdowns
shimmer 1.5s Loading skeletons
pulse-ring 1.5s Cart badge, notifications

Apply via Tailwind classes: animate-fade-in, animate-slide-up, animate-shimmer, etc.

πŸ€– Bot

Telegram bot for order management.

cd bot
uv sync
uv run python -m bot.main

Bot features:

  • Browse products
  • Add to cart via messages
  • Place orders
  • Track order status
  • Telegram auth login

🐳 Docker

Development

make dev           # Start all services
make stop          # Stop all services
make logs          # Backend logs
make shell-backend # Bash inside backend container
make shell-db      # psql inside postgres

Production

# Build and start in production mode
make prod

# Build images only
make build

Docker services

Service Port Description
frontend 3000 Next.js (dev) / Nginx (prod)
backend 8000 FastAPI REST API
postgres 5432 PostgreSQL 16
redis 6379 Redis 7 (caching, sessions)
minio 9000 S3 storage API
minio-console 9001 MinIO web console

πŸ“š API Documentation

Interactive Swagger UI: http://localhost:8000/api/docs

ReDoc alternative: http://localhost:8000/api/redoc

πŸ§ͺ Quality

# Backend
make lint              # ruff check + autofix
make test              # pytest
make verify            # import check + frontend typecheck

# Frontend
pnpm lint              # ESLint
pnpm typecheck         # tsc --noEmit

πŸ“¦ Deployment

Prerequisites

  1. Set all .env variables (see .env.example)
  2. SECRET_KEY β€” at least 32 characters, generate with: python -c "import secrets; print(secrets.token_urlsafe(32))"
  3. BOT_TOKEN β€” from @BotFather on Telegram
  4. Domain and SSL certificate for Nginx

Steps

# 1. Pull latest code
git pull

# 2. Copy .env (production values)
cp .env.production .env

# 3. Build and start
make build
make prod

# 4. Run migrations
docker-compose exec backend uv run alembic upgrade head

Nginx SSL (optional)

Add to frontend/nginx.conf:

listen 443 ssl;
ssl_certificate /etc/ssl/certs/domain.crt;
ssl_certificate_key /etc/ssl/private/domain.key;

🀝 Contributing

  1. Create feature branch: git checkout -b feature/name
  2. Follow Backend and Frontend standards
  3. Run make lint and make test before committing
  4. Submit PR with description

πŸ“„ License

Private β€” E-Commerce Platform

About

No description, website, or topics provided.

Resources

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors