How shiksha-nath02/echoverse works
EchoVerse is a full-stack web application:
• Client: React + Vite SPA (client/) that renders pages/components and calls a REST API via Axios.
• Server: Node.js + Express REST API (backend/) implementing authentication + posts (and likely comments, per README).
• Data layer: PostgreSQL accessed through Prisma ORM (backend/prisma/schema.prisma, migrations/).
• Auth: JWT-based auth with an Express middleware (backend/middleware/auth.js).
Frontend (client/)
• client/src/main.jsx + App.jsx: SPA bootstrap + top-level routing layout
• client/src/pages/*: route-level screens (Login, Signup, Dashboard, AdminPortal, ShowPost, NewPost, Logout)
• client/src/Components/*: shared UI + routing guards
• PrivateRoute.jsx / PublicRoute.jsx: important—they indicate the client enforces auth gating in the UI
• client/src/Services/api.js and client/src/api/* (auth.js, posts.js): API client layer (Axios wrapper + endpoint-specific functions)
• client/src/store/store.js: global state (auth/user state is likely stored here)
• “Routing + Pages”
• “Auth Guards (PrivateRoute/PublicRoute)”
• “API Client (Axios)”
• “State Store”
Backend (backend/)
Key nodes:
• backend/index.js: Express app entrypoint; likely mounts routes and middleware
• backend/routes/auth.js, backend/routes/posts.js: route modules
• backend/controllers/authcontroller.js, backend/controllers/postCtrl.js: request handlers / business logic
• backend/middleware/auth.js: JWT verification / protection of routes
• backend/prisma/schema.prisma + migrations/*: data model + schema evolution
• “Routes”
• “Middleware (JWT auth)”
• “Controllers / Services (business logic)”
• “Prisma Client (ORM)”
• “PostgreSQL DB”
Database layer
From README Prisma schema:
• Entities: User, Post, Comment
• Relations: User→Posts, Post→Comments, User→Comments
Signup/Login
• Browser (Login/Signup page) → Axios (client/src/api/auth.js) → Express /api/auth/*
• Express routes → authcontroller.js
• authcontroller.js → Prisma → Postgres (create/find user)
• Response returns JWT (and possibly user payload)
Authenticated session
• Browser stores JWT (likely in store/local storage; not shown but implied)
• Subsequent API calls include JWT in Authorization: Bearer <token> (usually done in Services/api.js)
• Express middleware/auth.js validates JWT and attaches user context to request
Read posts
• Dashboard/Home → client/src/api/posts.js → GET /api/post
• Express routes/posts.js → postCtrl.js → Prisma → Postgres
Create post
• NewPost page → POST /api/post
• Protected by middleware/auth.js (very important to show)
Comments (README mentions it, repo doesn’t show route file)
• “Comments API” component (even if route file is not visible) OR
• As “planned/expected endpoint per README”
• SPA + REST: React SPA consumes REST endpoints from Express.
• Route → Controller separation on backend: routes/ delegates to controllers/.
• Middleware-based security: middleware/auth.js acts as a gatekeeper for protected routes.
• Data access via ORM: Prisma is the only component that talks to Postgres.
• Shared domain model: Prisma schema defines the domain entities (User, Post, Comment).
Level 0: System Context (1 slide)
• Actors: “User (Browser)”
• Systems: “EchoVerse Web App (React SPA)”, “EchoVerse API (Express)”, “PostgreSQL”
• External: none obvious (no S3, no email provider, etc.)
• Browser ↔ React SPA (static assets)
• React SPA ↔ Express API (JSON/HTTPS)
• Express API ↔ Postgres (SQL via Prisma)