How h-hamdy/focustracker works
Project type and purpose
• FocusTrack is a full-stack web application for Pomodoro-style time tracking, analytics, and user ranking.
• Frontend is built with Next.js; backend is built with NestJS and Prisma ORM; data is stored in PostgreSQL.
File structure
• Top-level directories:
– frontend/ – Next.js app, UI pages under app/auth and app, global CSS, Tailwind config
– backend/ – NestJS modules (auth, prisma, core app), Prisma schema and migrations, test suites, lint/build configs
• Patterns & configurations:
– NestJS modules map to domain areas: auth, prisma
– Prisma directory holds schema.prisma and migrations → database layer
– Swagger decorators likely in controllers for API docs
– Railway deployment descriptors are implied (no Dockerfile present)
README for additional insights
• Key features: JWT auth, Pomodoro timer (real-time & manual tracking), analytics charts, weekly leaderboard
• AES-256 encryption for sensitive data at rest
• Swagger for API documentation
• Deployment on Railway for frontend, backend, database
a. Main components
1. Client / Browser (Next.js UI)
2. Frontend server (Next.js on Vercel/Railway)
3. Backend API (NestJS REST controllers)
4. Database (PostgreSQL with Prisma)
5. External/Infrastructure services: Railway, Swagger UI, JWT issuer, AES-256 encryption module
b. Relationships & interactions
• User ↔ Next.js UI: HTTP(S) for rendering pages & fetching data via client-side calls
• Next.js UI ↔ NestJS API: REST calls (Axios/fetch) with Bearer JWT in headers
• NestJS API ↔ PostgreSQL: Prisma client executes SQL for CRUD, migrations apply schema changes
• Auth service issues and verifies JWT; encryption service handles AES-256 when persisting sensitive fields
• Swagger UI exposes /api-docs endpoint for interactive API exploration
c. Architectural patterns & design principles
• Modular monolith on the backend: NestJS modules per domain (auth, prisma, app)
• MVC-style on backend: Controllers → Services → ORM (Prisma)
• Component-based UI in Next.js (app/ directory + shared ui components)
• Secure layering: transport (HTTPS), JWT at API layer, encryption at data layer
d. Key technologies & libraries
• Frontend: Next.js routing/app directory, Tailwind CSS, ESLint, utility functions in lib/utils.ts
• Backend: NestJS, TypeScript, Prisma ORM, JWT (@nestjs/jwt), AES-256 encryption library, Jest for tests
• Database: PostgreSQL (migrations in prisma/migrations)
• DevOps: Railway for hosting, Swagger (via @nestjs/swagger)
Elements
– UI → API (with “REST/HTTPS + JWT”)
– API → Database (with “Prisma ORM/SQL”)
– API ↔ Encryption service (“AES-256”)
– Blue for UI components
– Green for backend modules
– Orange for data persistence layer
– Purple for external services
– Rounded rectangles for services/modules