How kingreapermax/copsweek works
Project type and purpose
• This is a monolithic, server-rendered full-stack web application built with Node.js/Express and EJS templates.
• Purpose: a “Civic Portal” where authenticated users can register, log in, post infrastructure complaints, and view both a general dashboard and personal profile pages.
File structure
• Top-level:
• .gitignore, README.md
• server/ – main application code
• Inside server/:
• index.js – Express app entry point (routes, middleware)
• database.sql – PostgreSQL schema and table definitions
• package.json & lock – dependencies and scripts
• public/ – static assets (CSS)
• views/ – EJS templates (login, register, dashboard, user) plus shared partials (header/footer)
• Patterns:
• MVC-style separation:
– Views: views/
– Controller & router logic in index.js (could be refactored into controllers/, routes/ dirs)
– Model: SQL schema + database connection in index.js
• JWT authentication middleware protecting API/endpoints
README for additional insights
• Tech stack: Node.js, Express, EJS, PostgreSQL, JWT
• Authentication flow: registration/login → issue JWT → subsequent API requests carry token
• Workflows:
• Public pages: login, register
• Protected pages: dashboard, user profile
• Data flow: user complaint posts → saved in PostgreSQL → retrieved for dashboard
Elements
• Clear labels: “Browser / Client,” “Express.js Server,” “JWT Auth Module,” “PostgreSQL DB,” etc.
• Request flow: browser → server → DB
• Response flow: DB → server → browser
• Token issuance: server → browser
• Rectangles for components
Final advice
• How EJS templates tie into the view layer.
• JWT token storage and usage cycle.
• Don’t overthink—capture every logical piece (client, routes, auth, DB, static files, views) to make the architecture crystal clear.