How italo-gouveia/myanimeapi works
Project type and purpose
• MyAnimeAPI is a full-stack web application.
• The frontend is a Next.js/React app that handles user interactions (login, register, profile, browsing anime).
• The backend is a Go REST API (using Gorilla Mux) providing CRUD endpoints for anime, users, reviews, plus JWT auth, rate limiting, and validation.
• It persists data in PostgreSQL (via GORM), is containerized with Docker, and uses GitHub Actions for CI/CD.
File structure
• Top-level directories:
• cmd/ – application entrypoints, Swagger docs generator
• api/ – HTTP handlers, routes, middleware, mocks, auth, database wrappers
• internal/ – config loader, database migrations, DB interface, utilities, error definitions
• frontend/ – Next.js code (pages, components, API client, hooks)
• tests/ – unit, integration, E2E, smoke test code
• assets/, Dockerfile, docker-compose.yml, .github/workflows – deployment and CI/CD
• The Go code is organized around handlers → middleware → routers → models → internal services
• The frontend is a self-contained client that calls the Go API at /v1 endpoints.
README for additional insights
• Describes API endpoints, technologies, features (auth, pagination, rate limiting)
Diagramming the system architecture
a. Main components:
• Client (browser/mobile) running the Next.js frontend
• Next.js Server (SSR/static assets)
• Go REST API Server (Gorilla Mux)
• PostgreSQL database
• Middleware chain (auth, rate limit, logging, sanitization, error handling)
• CI/CD pipeline (GitHub Actions)
• Docker & Docker-Compose orchestration
• External: Swagger UI, JWT issuer, possibly third-party auth (if any)
b. Relationships & interactions:
• Client → (HTTP/HTTPS) → Next.js server → (HTTP/HTTPS) → Go API
• Go API → (SQL via GORM) → PostgreSQL
• Go API ←→ internal/config for environment variables
• GitHub pushes trigger CI workflow → build Docker image → run tests → push to registry → deploy
c. Architectural patterns & principles:
• Layered architecture (HTTP layer → middleware → handler → service → data layer)
• Separation of concerns: “api” for HTTP, “internal” for business logic/config/db, “frontend” for UI
• Stateless services, JWT for auth, rate limiting for resiliency
• Micro-components approach: each middleware is a discrete unit
d. Key technologies & frameworks:
• Frontend: Next.js, React, TypeScript, ESLint, PostCSS
• Backend: Go, Gorilla Mux, GORM, JWT
• Database: PostgreSQL
• Containerization: Docker, Docker-Compose
• CI/CD: GitHub Actions
• Documentation: Swagger
Detailed capture of essential elements
• For the frontend, show Next.js SSR vs. static assets vs. API invocation.
• .env/config component feeding settings into both frontend and backend.
• Docker network connections between containers.
• Port mappings (e.g., :8080 for API, :3000 for Next.js if applicable).