This is the backend for the Steam application, built with Node.js, Express, Prisma, and PostgreSQL. It includes authentication using Auth0 and various endpoints for managing user profiles, complaints, and more.
-
Clone the repository:
git clone /~https://github.com/yourusername/steam-backend.git cd steam-backend
-
Install dependencies:
npm install -g pnpm pnpm install
-
Set up the database:
pnpx prisma migrate dev --name init
Create a
.env
file in the root directory and add the following environment variables:
DATABASE_URL="postgresql://<username>:<password>@<host>:<port>/<database>?schema=<schema>"
POSTGRES_PASSWORD="<your_postgres_password>"
NODE_ENV="production"
AUTH_SECRET="<your_auth_secret>"
BASE_URL="<your_base_url>"
CLIENT_ID="<your_client_id>"
ISSUER_BASE_URL="<your_issuer_base_url>"
GOOGLE_CLIENT_ID="<your_google_client_id>"
GOOGLE_CLIENT_SECRET="<your_google_client_secret>"
-
Start the application:
node index.js
-
The server will be running on
http://localhost:8032
.
- GET /checkSession: Check if the user is authenticated.
- GET /letmein: Redirects to login if not authenticated, otherwise logs in the user.
- GET /self: Get the authenticated user's profile information.
- PUT /profileUpdate: Update the authenticated user's profile.
- GET /complaints: Get all complaints (admin only).
- PUT /complaintStatus: Change the status of a complaint (admin only).
- POST /complaint: Submit a new complaint.
- GET /myComplaints: Get the authenticated user's complaints.
- GET /map: Get the heatmap for a given location.
-
Build and run the Docker containers:
docker-compose up --build
-
The backend will be running on
http://localhost:8032
and the NGINX server will be running onhttps://localhost
.
.
├── .dockerignore
├── .env
├── .env.example
├── .gitignore
├── backend.Dockerfile
├── compose.yaml
├── index.js
├── map.html
├── nginx.conf
├── package.json
├── pnpm-lock.yaml
├── prisma
│ ├── schema.prisma
├── ssl
│ ├── nginx.crt
│ ├── nginx.key
└── foli.py
This project is licensed under the MIT License.
Your architecture integrates multiple components to provide a seamless, secure, and scalable solution. Below is a breakdown of each part of the system:
-
Docker
- Containerized setup ensures modular and portable development.
- Services hosted as containers:
- webServer (Node.js): Hosts backend APIs.
- Database (PostgreSQL): Stores application data.
- Nginx: Acts as a reverse proxy and handles SSL termination.
- Facilitates orchestration of services and simplifies deployment.
-
Cloudflared (Cloudflare Tunnel)
- Exposes the locally deployed Docker services to a publicly accessible domain.
- Uses Cloudflare DNS for routing traffic securely.
- Eliminates the need for direct public IP exposure.
-
Next.js (React-based Framework)
- Developed for the user-facing application.
- Fetches data from backend APIs to perform CRUD operations.
- Implements CI/CD pipeline with Cloudflare Pages:
- Code hosted on GitHub.
- Automatic builds and deployments triggered on new commits.
-
Heatmap Generation
- Coordinates collected from user interactions are sent to the backend via fetch requests.
- Frontend displays processed heatmaps to users and NGOs after receiving results.
- Auth0
- Middleware service for user authentication and management.
- Provides secure user discretization and role-based access control (e.g., users, NGOs).
-
Node.js Backend
- Manages API requests from the frontend.
- Performs CRUD operations on the PostgreSQL database.
- Acts as a gateway for processing heatmap data.
-
Integration with Deep Learning Model
- Backend forwards heatmap coordinates to a dedicated Deep Learning Model API.
- The model processes the data and returns relevant results.
- Backend relays processed data to the frontend.
- PostgreSQL
- Relational database for structured storage of user, heatmap, and application data.
- Optimized for performance and scalability with Dockerized setup.
-
Nginx (SSL Termination)
- Encrypts data in transit between clients and server using HTTPS.
- Manages load balancing and reverse proxy to backend services.
-
Cloudflare
- Protects the domain from attacks using DDoS protection and Web Application Firewall (WAF).
- Ensures low-latency delivery through its global CDN.
-
Frontend to Backend
- Frontend sends API requests (e.g., CRUD operations, heatmap coordinates).
- Backend processes requests and communicates with PostgreSQL or the Deep Learning Model API.
-
Backend to Deep Learning Model
- Heatmap data sent for analysis.
- Processed results returned to backend.
-
Frontend to Users/NGOs
- Processed heatmaps and relevant data are displayed to users in real time.
-
Frontend
- Code changes on GitHub trigger Cloudflare Pages for automatic builds and deployments.
-
Backend
- Dockerized services allow rapid updates with minimal downtime.