How void0428/ecommerce works
Project Type and Purpose
• This is a modern full-stack e-commerce application (“Fashion Store”) with:
• Frontend: React SPA built and served via Vite
• Backend: Django + Django REST Framework
• Purpose: Allow users to browse products, manage carts, place orders, handle authentication, and send email notifications.
File Structure
• Top-level directories:
• backend/ – Django REST API
• frontend/ – React application
• In backend/:
• ecommerce_backend/ – Django project configuration (settings, URLs, ASGI/WSGI)
• apps: products/, orders/, users/, notifications/
• templates/emails/ – Email templates for order/cart notifications
• manage.py, requirements.txt, .env
• In frontend/:
• src/components/ – UI components (Navbar, Hero, ProductCard, etc.)
• src/pages/ – Page views (Home, Cart, Checkout, Login, etc.)
• src/context/ – React Context for Auth and Cart state
• src/services/api.js – Axios instance for API calls
• Vite config, package.json
README for Additional Insights
• Tech stack: Django 4.2.7, DRF, SQLite, React 18, Vite, React Router, Axios
• API endpoints grouped by products, orders/cart, authentication
• Database models: Category, Product, Cart, CartItem, Order, OrderItem, User
• Notifications via email templates and a notifications utils module
• CORS configured to allow frontend origin.
Main Components
a. Frontend
• Browser / React SPA (Vite development/build)
• Components & Pages
• Context Providers (AuthContext, CartContext)
• API Service (Axios)
b. API Gateway
• Django REST Framework routers and URL configuration
• Middleware (CORS, custom middleware)
c. Business Logic
• Users app (authentication, registration, user profile)
• Products app (listing, filtering, categories, details)
• Orders app (cart management, checkout, order tracking)
• Notifications app (email triggers via Django signals)
d. Data Layer
• Relational database (SQLite in dev; PostgreSQL in prod)
• Media storage (backend/media/products for product images)
e. External Services
• Email service (SMTP or third-party)
• Optional: CDN or object storage for media/static
Relationships and Interactions
• Frontend → API: HTTP(S) requests (GET, POST) via Axios to endpoints under /api/
• API Gateway → Business Logic: Requests dispatched to DRF ViewSets or APIViews in each app
• Business Logic → Database: ORM queries and migrations handle data persistence
• Orders app emits signals → Notifications utils → Email Service
• Authentication tokens or session identifiers passed in headers/cookies → Users app validates → DB
• Media uploads/downloads served by Django or external storage
Key Architectural Patterns and Principles
• Separation of concerns:
• Presentation (React) vs. API/Business logic (Django) vs. Data persistence
• RESTful API design via Django REST Framework
• Contextual state management on the client side
• Modular Django apps for each domain (users, products, orders)
• Event-driven notifications using Django signals
• Environment-based configuration via .env and settings.py