How rifqoooh/zoincas works
Project type and purpose
• This is a full-stack Next.js (App Router) web application for personal finance management (budgets, balances, categories, transactions), with both public marketing pages (src/app/(web)), authenticated user dashboard (src/app/(main)), and an admin interface (src/app/(admin)). The backend is implemented via Next.js serverless API routes (src/app/api), using Drizzle ORM for the database, Redis for caching/rate-limiting, Zod for validation, and external services like OpenAI (AI route) and Sentry (error monitoring).
File structure
• Top-level Next.js config and dependencies (next.config.ts, package.json, drizzle.config.ts)
• src/app directory:
• (web): static marketing pages
• (auth): authentication flows (sign-in, sign-up)
• (main): client-side dashboard pages, protected by middleware
• (admin): admin UI, protected by admin middleware
• /api/[[...route]]/_routes: modular route handlers for sessions, users, balances, budgets, categories, transactions, summaries, AI
• src/lib:
• api utilities (router creation, OpenAPI, RPC)
• auth client/server
• db schema, seeds, service functions (CRUD logic)
• redis utilities and rate-limiter
• src/hooks & src/providers: React Query hooks (queries, mutations, stores) and context providers (auth, theme, query client)
• src/components: UI component library, form and modal components, data tables, charts, sidebars
• src/middleware: page and API middleware for auth/enforcement
• src/validators: Zod schemas for API and DB
README for additional insights
a. Main components:
• Client (Browser)
• Next.js App (Edge + Server):
– App Router (SSR/SSR as needed)
– Page Middleware (auth, admin)
– API Router (modular route handlers)
• Business Logic Layer (src/lib/db/services, validators)
• Database (PostgreSQL/MySQL via Drizzle ORM)
• Cache/Rate-Limiter (Redis)
• External Services:
– OpenAI/Gemini API (AI route)
– Sentry (error monitoring)
– Vercel (hosting/CDN)
b. Relationships & data flows:
1. User → Browser UI → Next.js pages (rendered server-side or client-side)
2. UI actions → React Query hooks → fetch to API routes
3. API route → middleware (auth/admin) → handler → validators → DB service → Drizzle → Database
4. Handler may also call Redis for caching or rate-limiting, or call OpenAI API.
5. Errors and performance data sent to Sentry.
c. Architectural patterns & design principles:
• Layered architecture (Presentation, API, Service, Data)
• Separation of concerns: UI components vs. hooks vs. services vs. validators
• Modular API routing under Next.js App Router
• Use of middleware for cross-cutting concerns (auth, admin)
• Type safety and validation with Zod at both API and DB layers
d. Key technologies & frameworks:
• Next.js (App Router, serverless functions)
• React Query (data fetching & caching)
• Drizzle ORM (database schema & queries)
• Redis (cache & rate limiter)
• Zod (validation)
• OpenAI API (AI features)
• Sentry (monitoring)