How rainycitycoder/sby-backend works
Project type and purpose
• This is a full-stack web application (“Scientist Birthdays”) with a React.js front-end (deployed to AWS S3) and a Django REST back-end (deployed on AWS EC2). The front-end reads two API endpoints (/bio/ and /compsci/) and displays data from a local SQLite3 database.
File structure
• Top-level directories and files:
• pythonbackend/ – Django project (settings.py, asgi.py, wsgi.py, urls.py)
• api/ – Django “app” housing models, serializers, views, URLs, tests, and migrations
• gunicorn/ – Service unit file for Gunicorn on the EC2 host
• nginx/ – nginx.conf for reverse-proxy configuration
• scripts/ – provisioning & startup scripts (install dependencies, configure nginx, start Gunicorn, after_install)
• manage.py, requirements.txt, db.sqlite3 – Django entry point, Python dependencies, database
• These indicate a classic monolithic Django API behind Gunicorn + Nginx, plus automated deployment scripts.
README for additional insights
• Confirms React front-end (hosted separately), minimal routing, automatic API calls
• Django REST endpoints for two resource paths
• SQLite3 used for persistence
• Deployment to AWS S3 (front end) and AWS EC2 (back end)
Main components
a. Front-End Layer
• AWS S3 Bucket (Static Website Hosting)
• Browser (React SPA)
b. Network/Edge Layer (optional)
• Amazon Route 53 / DNS
• (Optionally) Amazon CloudFront CDN in front of the S3 bucket
c. Back-End Layer on AWS EC2
• Nginx (reverse proxy, static file serving if any)
• Gunicorn (WSGI server managing Django processes)
• Django REST Framework application (“pythonbackend” + “api” modules)
• SQLite3 Database (db.sqlite3 file)
d. DevOps/Automation
• Provisioning & startup scripts (in “scripts/”)
• Systemd service for Gunicorn (“gunicorn/gunicorn.service”)
• nginx.conf (in “nginx/”)
Relationships and interactions
• Browser loads static assets from S3 (HTTP GET).
• React components in the browser issue fetch() calls to API endpoints (e.g., https://api.example.com/bio/).
• Requests route via DNS → EC2 public IP → Nginx listens on port 80/443 → proxies to Gunicorn on a local port.
• Gunicorn forwards requests to Django’s ASGI/WSGI endpoint.
• Django ORM reads/writes to the local SQLite3 file.
• Responses flow back up from Django → Gunicorn → Nginx → Browser.
Architectural patterns & design principles
• Separation of concerns: Static SPA vs. dynamic API
• Reverse-proxy pattern: Nginx decoupling TLS, caching, static vs dynamic routing
• Process manager: Gunicorn for concurrency/worker management
• Infrastructure as code: Shell scripts for repeatable deployments
• Single instance monolith: all Django code and SQLite in one EC2 instance
Essential architectural elements
• Don’t omit the reverse-proxy layer (Nginx) nor the WSGI server (Gunicorn).
• Automation and config artifacts (scripts, systemd unit, nginx.conf) to reflect deploy operations.
• Separation of static vs dynamic content, showing AWS S3 as a separate component.