How tlokeshgit/greencart-microservices works
Project type and purpose
• This is a single‐service backend application (GreenCart Backend) built with Django and Django REST Framework.
• It provides RESTful APIs for an e-commerce platform: user/auth management, product/category management, shopping cart, orders, payments (Stripe), coupons, ratings, etc.
File structure analysis
• Top‐level:
• build.sh, render.yaml (deployment)
• django_backend/ (Python package)
• .env, .gitignore, README.md
• Inside django_backend:
• manage.py, asgi.py, wsgi.py, settings.py, requirements.txt
• shop/ Django app: models.py, serializers.py, views.py, urls.py, admin.py, tests.py
• templates/ (HTML for homepage, Swagger UI, password-reset flows)
• static/ (CSS/JS for admin and frontend)
• insert_dummy_data.sql
• root urls.py ties shop.urls and swagger/redoc routes
README insights
• Confirms Django + DRF stack
• Describes features, deployment on Render.com (Python service + PostgreSQL managed DB)
• Build & start commands (build.sh, gunicorn django_backend.wsgi)
• API docs served via Swagger and ReDoc endpoints
a. Main components
• Clients (Web browser, Mobile app)
• Render.com load balancer / HTTPS endpoint
• Gunicorn (WSGI) / ASGI server
• Django application (django_backend package)
– Core modules: Authentication, Shop app (products, orders, coupons, ratings)
– REST Framework layer (serializers, viewsets, routers)
– Static & template engine (serving admin UI, Swagger UI)
• PostgreSQL database (Render managed)
• External services: Stripe (payment processing)
• Optional: Redis or cache layer (if added later), email SMTP service for password reset
b. Relationships & data flow
1. Client → HTTPS → Render load balancer → Gunicorn/ASGI → Django URL router
2. Django routes to corresponding viewsets in shop app
3. Business logic executes: models read/write to PostgreSQL via Django ORM
4. Payment endpoints invoke Stripe API over HTTPS
5. Responses return back through the same path to client
6. Static assets and Swagger UI served either by Django staticfiles or CDN if configured
c. Architectural patterns & design principles
• Modular “apps” per domain (Django’s app structure)
• Layered architecture:
• Presentation (templates, Swagger UI)
• API layer (DRF viewsets/serializers)
• Business logic (models, services)
• Data layer (ORM → PostgreSQL)
• 12-factor app principles (env variables, build script, stateless server)
• Externalizing config (DJANGO_SETTINGS_MODULE, DATABASE_URL)
d. Key technologies
• Python 3.x, Django, Django REST Framework
• Gunicorn (WSGI), ASGI for async
• PostgreSQL
• Stripe SDK
• Render.com deployment (render.yaml)
• Swagger / ReDoc for API docs
Detailed breakdown
• Layer 1 (Edge): Client devices → HTTPS
• Layer 2 (Ingress): Render.com static route → build & deploy (build.sh, render.yaml)
• Layer 3 (Application):
• Gunicorn/ASGI server
• Django core (settings, URL dispatch)
• shop app modules (models, serializers, views)
• admin & Swagger UI templates/static
• Layer 4 (Persistence & integrations):
• PostgreSQL (data store)
• Stripe API (payment)
• SMTP/email (user notifications)