How refusado/gerenciar-influenciadores works
Project Type and Purpose
• This is a full-stack JavaScript application providing an administrative platform for managing influencers and brands.
• Frontend: Next.js (React) delivering both public routes (login/signup) and a protected admin SPA.
• Backend: Fastify-based monolithic API server that also serves the built Next.js static assets.
• Database: Relational (managed via Prisma ORM).
• External service: ViaCEP API for address lookup.
File Structure
• Top-level folders:
• backend/ – Fastify server, Prisma migrations, API routes, controllers, utilities, tests, Swagger docs.
• frontend/ – Next.js “app” directory, React components, hooks, API clients, Tailwind styles, config.
• Important files:
• backend/src/api-routes/public & private → delineate open vs. authenticated endpoints.
• backend/prisma/schema.prisma + migrations → data model and evolution.
• frontend/src/app/(plataform) → public login/signup pages.
• frontend/src/app/admin → admin pages and internal API clients.
• Config & tooling: ESLint, Prettier, Zod, Vitest, Supertest, Axios, TanStack Query.
Key Insights from README
• Authentication system securing both API and web routes.
• CRUD for influencers/brands, plus association between them.
• Data validation end-to-end (Zod + TypeScript).
• Swagger/OpenAPI docs at /api/docs.
• Next.js in SSG mode for public and private SPAs, served by Fastify in production.
Main Components
a. Client (Browser)
• Public UI (login, signup)
• Admin UI (protected dashboard pages)
b. Next.js Frontend
• App router – SSG/SSR for public pages
• Bundled React SPA for admin
• Static assets (CSS, JS)
c. Fastify Server
• Static file serving (built Next.js output)
• API router – public vs. private routes
• Controllers & business logic
• Error-handling & validation (Zod integration)
• Swagger UI endpoint
d. Prisma ORM + Database
• Schema definitions & migrations
• CRUD operations
e. External Services
• ViaCEP REST API for address lookup
f. Developer Tools (optional to show)
• Vitest/Supertest test runner
• ESLint/Prettier pipeline
Relationships & Data Flow
• Browser → HTTP GET/POST → Next.js pages (public)
• Browser → API calls (Axios/TanStack Query) → Fastify endpoints
• Fastify → Prisma → Database
• Fastify → Axios → ViaCEP → Fastify → Database
• Fastify → serves built Next.js static files to Browser
• Swagger UI (served by Fastify) reads OpenAPI JSON
Architectural Patterns & Principles
• Layered architecture: Presentation (Next.js) → API layer (Fastify routes/controllers) → Data layer (Prisma/DB).
• Separation of concerns: public vs. private API namespaces.
• End-to-end type safety & validation (TypeScript + Zod).
• Monorepo with two sub-projects sharing types and validation rules.
• SPA-style data fetching in admin using TanStack Query with optimistic updates.
Essential Elements to Capture
• Public vs. private route separation in both Next.js and Fastify.
• Data validation layer (Zod) at API boundary.
• API documentation endpoint (Swagger UI).
• Prisma migrations & schema as the source of truth for data model.
• Axios + TanStack Query for client-side data fetching.