# codegirls-1tdspb/sprint-4 architecture

> Architecture diagram of the GitHub repository codegirls-1tdspb/sprint-4, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-23). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/codegirls-1tdspb/sprint-4
- Repository: https://github.com/codegirls-1tdspb/sprint-4

## Overview

##### Project type and purpose
- This is a full-stack Next.js (v13+) application written in TypeScript.
- The “src/app” folder uses the App Router for both UI routes (pages and components) and API routes under “src/app/api”.
- Purpose: a dashboard-style web app that manages users, teams, tasks (tarefas), alerts (alertas), notifications (notificação) and login/profile flows.

##### File structure
- Top-level directories:
- public/ — static assets (images).
- src/app/ — Next.js pages (layout.tsx, page.tsx), sub-folders per feature/domain (dashboard, login) and API endpoints.
- src/components/ — shared UI components (Header, Footer, Cards, Logo).
- src/lib/ — shared business logic (auth.ts).
- src/hoc/ — higher-order components (withAuth.tsx).
- src/data/ — sample data (listaDeUsuarios.ts).
- Configuration: next.config.ts, tailwind.config.ts, postcss.config.mjs, eslint.config.mjs, tsconfig.json.

##### README
- Minimal content (“# Sprint-4”).

##### Main components and their relationships
a. Frontend (Browser / Client)
- Next.js App Router → server-side & client-side rendering
- Components (pages under “login” and “dashboard”, UI components under src/components)
- withAuth HOC for protected routes
b. API Layer (Next.js Serverless / Node.js)
- RESTful endpoints under src/app/api/{alertas,equipes,login,notificacao,tarefas,usuarios}
- Each domain folder holds [id]/route.ts and route.ts → standard CRUD routes
- auth.ts in src/lib handles token verification or session logic
c. Persistence Layer
- A database (e.g., PostgreSQL or MongoDB) storing tables/collections: Users, Teams, Tasks, Alerts, Notifications
- The API layer connects via an ORM/driver (not shown, but implied)
d. Static Assets & Styles
- public/imagens → images served by Next.js static serving
- Tailwind CSS & PostCSS → styling pipeline
e. External Services (optional)
- Email or push notification service for “notificação”
- Auth provider (if JWTs or OAuth used)

##### Important architectural patterns
- File-based routing for both UI and API.
- Separation of concerns:
- UI (pages, components)
- Business logic (src/lib)
- Data (API routes)
- Auth via HOC and lib
- Protected routes via withAuth → middleware pattern.
- RESTful domain-driven folder structure.

##### Final checklist for the engineer
- Related API routes into domain bundles.
- Technology stack near each component.
- Export in a high-resolution format for readability.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client
    Browser["Browser\n(Client)"]:::client

    %% Frontend Layer
    subgraph "Frontend (Next.js UI)" 
        direction TB
        AppRouter["Next.js App Router\n(src/app)"]:::frontend
        LoginPage["Login Page & Form"]:::frontend
        DashboardPage["Dashboard Main Page"]:::frontend
        SubDashboard["Dashboard Features"]:::frontend
        LoginPage --> DashboardPage
    end

    %% API Layer
    subgraph "API Layer (Next.js Serverless)" 
        direction TB
        API_Alertas["Alertas API\n(/api/alertas)"]:::api
        API_Equipes["Equipes API\n(/api/equipes)"]:::api
        API_Login["Login API\n(/api/login)"]:::api
        API_Notificacao["Notificação API\n(/api/notificacao)"]:::api
        API_Tarefas["Tarefas API\n(/api/tarefas)"]:::api
        API_Usuarios["Usuários API\n(/api/usuarios)"]:::api
    end

    %% Persistence Layer
    Database[(Database)]:::db

    %% External Services
    subgraph "External Services"
        direction TB
        EmailService["Email/Push Notification"]:::external
        AuthProvider["Auth Provider"]:::external
    end

    %% Static Assets & Styles
    StaticAssets["Static Assets\n(public/imagens)"]:::static
    Styles["Tailwind & PostCSS"]:::static

    %% HOC and Lib
    WithAuth["withAuth HOC"]:::frontend
    AuthLib["Auth Utilities\n(src/lib/auth.ts)"]:::api

    %% Data Sample
    SampleData["Sample Data\n(listaDeUsuarios.ts)"]:::static

    %% Connections
    Browser -->|"renders"| AppRouter
    AppRouter -->|uses| LoginPage
    AppRouter -->|uses| DashboardPage
    DashboardPage -->|fetch| API_Alertas
    DashboardPage -->|fetch| API_Equipes
    DashboardPage -->|fetch| API_Tarefas
    DashboardPage -->|fetch| API_Notificacao
    DashboardPage -->|fetch| API_Usuarios
    LoginPage -->|POST /api/login| API_Login
    API_Alertas -->|"CRUD"| Database
    API_Equipes -->|"CRUD"| Database
    API_Tarefas -->|"CRUD"| Database
    API_Notificacao -->|"CRUD"| Database
    API_Usuarios -->|"CRUD"| Database
    API_Login -->|validate| AuthLib
    API_Login -->|"issue token"| AuthProvider
    API_Notificacao -->|send| EmailService
    AppRouter -->|serves| StaticAssets
    Styles --> AppRouter
    WithAuth --> AppRouter
    SampleData --> API_Usuarios

    %% Click Events
    click AppRouter "https://github.com/codegirls-1tdspb/sprint-4/tree/main/rail-response/src/app"
    click LoginPage "https://github.com/codegirls-1tdspb/sprint-4/blob/main/rail-response/src/app/login/page.tsx"
    click LoginPage "https://github.com/codegirls-1tdspb/sprint-4/blob/main/rail-response/src/app/login/LoginForm.tsx"
    click DashboardPage "https://github.com/codegirls-1tdspb/sprint-4/blob/main/rail-response/src/app/dashboard/page.tsx"
    click API_Alertas "https://github.com/codegirls-1tdspb/sprint-4/blob/main/rail-response/src/app/api/alertas/route.ts"
    click API_Alertas "https://github.com/codegirls-1tdspb/sprint-4/blob/main/rail-response/src/app/api/alertas/[id]/route.ts"
    click API_Equipes "https://github.com/codegirls-1tdspb/sprint-4/blob/main/rail-response/src/app/api/equipes/route.ts"
    click API_Equipes "https://github.com/codegirls-1tdspb/sprint-4/blob/main/rail-response/src/app/api/equipes/[id]/route.ts"
    click API_Login "https://github.com/codegirls-1tdspb/sprint-4/blob/main/rail-response/src/app/api/login/route.ts"
    click API_Login "https://github.com/codegirls-1tdspb/sprint-4/blob/main/rail-response/src/app/api/login/[id]/route.ts"
    click API_Login "https://github.com/codegirls-1tdspb/sprint-4/blob/main/rail-response/src/app/api/login/senha/route.ts"
    click API_Notificacao "https://github.com/codegirls-1tdspb/sprint-4/blob/main/rail-response/src/app/api/notificacao/route.ts"
    click API_Notificacao "https://github.com/codegirls-1tdspb/sprint-4/blob/main/rail-response/src/app/api/notificacao/[id]/route.ts"
    click API_Tarefas "https://github.com/codegirls-1tdspb/sprint-4/blob/main/rail-response/src/app/api/tarefas/route.ts"
    click API_Tarefas "https://github.com/codegirls-1tdspb/sprint-4/blob/main/rail-response/src/app/api/tarefas/[id]/route.ts"
    click API_Usuarios "https://github.com/codegirls-1tdspb/sprint-4/blob/main/rail-response/src/app/api/usuarios/route.ts"
    click API_Usuarios "https://github.com/codegirls-1tdspb/sprint-4/blob/main/rail-response/src/app/api/usuarios/[id]/route.ts"
    click WithAuth "https://github.com/codegirls-1tdspb/sprint-4/blob/main/rail-response/src/hoc/withAuth.tsx"
    click AuthLib "https://github.com/codegirls-1tdspb/sprint-4/blob/main/rail-response/src/lib/auth.ts"
    click SampleData "https://github.com/codegirls-1tdspb/sprint-4/blob/main/rail-response/src/data/listaDeUsuarios.ts"
    click StaticAssets "https://github.com/codegirls-1tdspb/sprint-4/tree/main/rail-response/public/imagens"

    %% Styles
    classDef client fill:#E0FFFF,stroke:#000,stroke-width:1px,font-size:20px
    classDef frontend fill:#ADD8E6,stroke:#000,stroke-width:1px,font-size:20px
    classDef api fill:#8FBC8F,stroke:#000,stroke-width:1px,font-size:20px
    classDef db fill:#FFA500,stroke:#000,stroke-width:1px,font-size:20px
    classDef external fill:#9370DB,stroke:#000,stroke-width:1px,font-size:20px
    classDef static fill:#D3D3D3,stroke:#000,stroke-width:1px,font-size:20px
```
