How koderkalash/teamops works
1. Repository shape
- This is a two-app monorepo: backend/ is a Node.js + Express API, and frontend/ is a Next.js App Router client.
- The top-level GitHub Actions workflow runs backend tests on push/PR, so CI is centered on API correctness rather than frontend build validation.
2. End-to-end request path
- User interaction starts in the Next.js app.
- Frontend pages call Next.js API routes under frontend/app/api/*, which proxy requests to the backend.
- Those proxy routes forward auth and payloads to the Express API, which reads/writes MongoDB through Mongoose models.
- This proxy layer keeps browser-to-backend traffic centralized and avoids direct cross-origin calls from the UI.
3. Frontend boundary
- The frontend is organized around App Router pages: login, signup, and a protected dashboard.
- components/ProtectedRoute.js and lib/auth.js indicate client-side route guarding and auth-state handling.
- lib/api.js and the API route proxies form the network abstraction, so UI code does not hardcode backend access details.
4. Backend application composition
- backend/src/app.js defines the Express application; backend/src/server.js starts the HTTP server.
- src/config/db.js handles MongoDB connection setup.
- The backend is layered in the conventional Express style: routes → middleware → controllers → models/utils.
5. Domain subsystems
- The main backend domains are auth, users, projects, and tasks.
- Each domain has its own controller, route file, and in most cases a model, which keeps resource-specific rules close to the relevant API surface.
- projectTask.route.js suggests task operations nested under projects where membership and ownership matter.
6. Data model and persistence
- MongoDB is the system of record, accessed via Mongoose schemas in backend/src/models.
- The models likely encode the core entities: users, projects, and tasks, plus embedded or referenced relationships for membership and assignment.
- Password hashing is handled in the user model layer via hooks, so credentials are never stored in plain text.
7. Authentication flow
- auth.controller.js, jwt.js, and auth.middleware.js show a JWT-based login/signup system.
- Public auth endpoints issue tokens after credential validation.
- Protected routes read the token through middleware before controller logic executes.
8. Authorization model
- Access control is multi-layered, not just “logged in vs not logged in.”
- role.middleware.js enforces role-based access (user, manager, admin) at the route level.
- Controllers also apply ownership and membership checks, especially for project and task mutations.
- Some actions are field-restricted, meaning a user may update only specific fields such as task status.
9. Reusable query and response behavior
- utils/apiFeatures.js provides shared list-query behavior such as filtering, searching, sorting, and pagination.
- This reusable abstraction is used across list endpoints to keep API behavior consistent.
- The project explicitly caps pagination at 50 items per page, which is an API-level performance guardrail.
10. Cross-cutting middleware
- globalLimiter.middleware.js and authLimiter.middleware.js indicate request throttling exists in targeted form, especially around auth endpoints.
- error.middleware.js centralizes error formatting, while asyncHandler.js reduces boilerplate around async controller failures.
- AppError.js provides a standard application error type for predictable API responses.
11. Testing and verification
- Backend integration tests live in backend/tests, with Jest and Supertest driving API-level verification.
- tests/setup.js and mongodb-memory-server imply isolated test runs against an in-memory MongoDB, avoiding dependence on a shared dev database.
- Current tests focus on authentication flows, and the GitHub Actions workflow enforces them in CI.
12. Architectural boundaries to capture in a diagram
- Keep the frontend, proxy API routes, backend API, and MongoDB as separate boxes.
- Show auth as a shared concern spanning frontend session handling, backend JWT issuance/verification, and route middleware.
- Show projects/tasks/users as separate backend subsystems feeding a shared persistence layer.
- Highlight that authorization is enforced in both middleware and controller logic, not only at the UI.
Main entry points: app.js Express App · models Models · api API Proxies · auth.controller.js Auth API
Components 21
Frontend
Next.js client and its API proxy layer
- App Router · Top-level pages and layouts for login, signup, and dashboard
frontend/app - Auth Pages · Login and signup screens
frontend/app/login/page.js - Dashboard · Authenticated landing area for the app
frontend/app/dashboard/page.js - Route Guard · Protects private frontend routes based on auth state
frontend/components/ProtectedRoute.js - Auth State · Client-side auth handling and token/session state
frontend/lib/auth.js - API Client · Shared frontend request abstraction
frontend/lib/api.js - API Proxies · Server-side proxy endpoints that forward browser requests to the backend
frontend/app/api - Auth Proxy · Login and signup proxy handlers
frontend/app/api/auth/login/route.js - Project Proxy · Project API proxy handler
frontend/app/api/projects/route.js
Backend
Express API with routes, controllers, middleware, and models
- Express App · Express application wiring for middleware and routes
backend/src/app.js - Server · Starts the HTTP server
backend/src/server.js - DB Connect · MongoDB connection bootstrap
backend/src/config/db.js - Auth API · Login, signup, token issuance, and verification
backend/src/controllers/auth.controller.js - Users · User resource endpoints and account rules
backend/src/controllers/user.controller.js - Projects · Project resource logic and ownership checks
backend/src/controllers/project.controller.js - Tasks · Task resource logic including project-scoped operations
backend/src/controllers/task.controller.js - Middleware · Auth, role, rate limiting, async handling, and errors
backend/src/middleware - Models · User, project, and task persistence models
backend/src/models - Query Utils · Shared filtering, search, sort, and pagination behavior
backend/src/utils/apiFeatures.js
Infra
MongoDB and CI/testing boundaries
- MongoDB · System of record for users, projects, and tasks
- Backend Tests · API integration tests run in CI
backend/tests
Connections 27
- App Router → Auth Pages: renders · App Router serves the public auth pages
- App Router → Dashboard: renders · App Router serves the protected dashboard
- Auth Pages → API Client: submits via · Auth pages use the shared client request layer
- Dashboard → Route Guard: protected by · Dashboard is wrapped by client-side route guarding
- Route Guard → Auth State: reads · Guard checks the client auth/session state
- Auth State → API Client: supplies auth · Client auth state informs outgoing requests
- API Client → API Proxies: calls · Frontend requests are sent to Next.js API routes
- API Proxies → Auth Proxy: includes · Auth-specific proxy handlers
- API Proxies → Project Proxy: includes · Project proxy handler
- API Proxies → Express App: forwards to · Proxy routes forward requests to the Express API
- Server → Express App: boots · Server entrypoint starts the Express app
- Express App → Middleware: uses · Express app mounts shared middleware
- Express App → Auth API: routes to · Auth endpoints reach the auth controller layer
- Express App → Users: routes to · User endpoints reach the user controller layer
- Express App → Projects: routes to · Project endpoints reach the project controller layer
- Express App → Tasks: routes to · Task endpoints reach the task controller layer
- Auth API → Models: writes/reads · Auth logic uses user persistence and password hooks
- Users → Models: writes/reads · User controller works with user documents
- Projects → Models: writes/reads · Project controller works with project documents
- Tasks → Models: writes/reads · Task controller works with task documents
- Models → MongoDB: persists in · Mongoose stores data in MongoDB
- Auth API → Middleware: protected by · JWT and rate-limit middleware gate auth flows
- Projects → Query Utils: lists via · Project listing uses shared query behavior
- Tasks → Query Utils: lists via · Task listing uses shared query behavior
- Middleware → MongoDB: validated against · Middleware and controllers ultimately operate over persisted state
- Backend Tests → Express App: verifies · Integration tests exercise backend API behavior
- Backend Tests → Auth API: covers · Current test focus centers on authentication flows