# jpavrdev/plataforma-estudos architecture

> Architecture diagram of the GitHub repository jpavrdev/plataforma-estudos, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jpavrdev/plataforma-estudos
- Repository: https://github.com/jpavrdev/plataforma-estudos

## Overview

ensina.dev is a free Portuguese-language learning platform. Learners browse trails and lessons, practice through quizzes, coding challenges, certification exams and spaced-repetition cards, then track progress and earn achievements or certificates. The React app calls an Express API backed by PostgreSQL; challenge execution and disposable Linux labs are isolated in separate services. The README documents the broader product areas, while some subsystem internals were not sampled, so their links are limited to documented relationships.

Main entry points: [`backend/app.ts`](https://github.com/jpavrdev/plataforma-estudos/blob/main/backend/app.ts) (HTTP API), [`frontend/src/App.tsx`](https://github.com/jpavrdev/plataforma-estudos/blob/main/frontend/src/App.tsx) (Web application), [`backend/src/controllers/TrailController.ts`](https://github.com/jpavrdev/plataforma-estudos/blob/main/backend/src/controllers/TrailController.ts) (Trail controller), [`backend/schema.ts`](https://github.com/jpavrdev/plataforma-estudos/blob/main/backend/schema.ts) (PostgreSQL data)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_learning["Learning experience"]
  node_webapp["Web application<br/>[App.tsx]"]
  node_authui["Account session<br/>[AuthContext.tsx]"]
  node_trailui["Trails and lessons<br/>[index.tsx]"]
  node_reviewui["Spaced review<br/>[index.tsx]"]
  node_homecontent["Home content<br/>[home.ts]"]
  node_roadmap["Roadmap service<br/>[roadmap.service.ts]"]
  node_simulado["Exam service"]
  node_flashcards["Flashcard service"]
end

subgraph group_platform["Platform API"]
  node_api["HTTP API<br/>[app.ts]"]
  node_authroutes["Authentication routes<br/>[auth.routes.ts]"]
  node_trailroutes["Trail routes<br/>[trail.routes.ts]"]
  node_trailcontroller["Trail controller<br/>[TrailController.ts]"]
  node_authcontroller["Authentication controller<br/>[AuthController.ts]"]
  node_authschema["Auth validation<br/>[auth.schema.ts]"]
  node_authmw["Authentication middleware<br/>[auth.ts]"]
  node_database[("PostgreSQL data<br/>[schema.ts]")]
  node_dbclient["Database client<br/>[db.ts]"]
end

subgraph group_progress["Progress and community"]
  node_stats["Progress statistics<br/>[stats.service.ts]"]
  node_streak["Study streak<br/>[streak.ts]"]
end

subgraph group_execution["Isolated execution"]
  node_runner["Challenge runner<br/>[server.mjs]"]
  node_labs["Linux labs<br/>[server.mjs]"]
  node_labws["Lab WebSocket<br/>[labs.ws.ts]"]
end

subgraph group_operations["Administration and services"]
  node_ats["Resume analysis<br/>[ats.service.ts]"]
  node_community["Community"]
  node_studio["Content studio<br/>[estudio.service.ts]"]
end

node_learner(("Learner"))

node_learner -->|"uses"| node_webapp
node_webapp -->|"provides session"| node_authui
node_webapp -->|"routes to"| node_trailui
node_webapp -->|"routes to"| node_reviewui
node_webapp -->|"uses"| node_homecontent
node_trailui -.->|"requests lessons"| node_api
node_reviewui -.->|"requests cards"| node_api
node_authui -->|"requests session"| node_api
node_api -->|"mounts"| node_authroutes
node_api -->|"mounts"| node_trailroutes
node_authroutes -->|"routes to"| node_authcontroller
node_authroutes -->|"applies limits"| node_authmw
node_authcontroller -->|"validates with"| node_authschema
node_trailroutes -->|"protects routes"| node_authmw
node_trailroutes -->|"routes to"| node_trailcontroller
node_trailcontroller -.->|"uses"| node_roadmap
node_trailcontroller -->|"uses"| node_studio
node_trailcontroller -->|"requests stats"| node_stats
node_authcontroller -->|"reads and writes"| node_database
node_stats -->|"queries"| node_database
node_streak -->|"queries"| node_database
node_dbclient -->|"connects"| node_database
node_api -->|"submits code"| node_runner
node_api -->|"serves lab sockets"| node_labws
node_labws -->|"issues sessions"| node_labs
node_api -.->|"serves exams"| node_simulado
node_api -.->|"serves review"| node_flashcards
node_api -.->|"serves resume analysis"| node_ats
node_api -.->|"serves community"| node_community
node_api -->|"calculates streak"| node_streak

click node_webapp "https://github.com/jpavrdev/plataforma-estudos/blob/main/frontend/src/App.tsx"
click node_authui "https://github.com/jpavrdev/plataforma-estudos/blob/main/frontend/src/contexts/AuthContext.tsx"
click node_trailui "https://github.com/jpavrdev/plataforma-estudos/blob/main/frontend/src/pages/TrilhaDetalhe/index.tsx"
click node_reviewui "https://github.com/jpavrdev/plataforma-estudos/blob/main/frontend/src/pages/Revisao/index.tsx"
click node_homecontent "https://github.com/jpavrdev/plataforma-estudos/blob/main/frontend/src/data/home.ts"
click node_api "https://github.com/jpavrdev/plataforma-estudos/blob/main/backend/app.ts"
click node_authroutes "https://github.com/jpavrdev/plataforma-estudos/blob/main/backend/src/routes/auth.routes.ts"
click node_trailroutes "https://github.com/jpavrdev/plataforma-estudos/blob/main/backend/src/routes/trail.routes.ts"
click node_trailcontroller "https://github.com/jpavrdev/plataforma-estudos/blob/main/backend/src/controllers/TrailController.ts"
click node_authcontroller "https://github.com/jpavrdev/plataforma-estudos/blob/main/backend/src/controllers/AuthController.ts"
click node_authschema "https://github.com/jpavrdev/plataforma-estudos/blob/main/backend/src/schemas/auth.schema.ts"
click node_authmw "https://github.com/jpavrdev/plataforma-estudos/blob/main/backend/src/middlewares/auth.ts"
click node_roadmap "https://github.com/jpavrdev/plataforma-estudos/blob/main/backend/src/services/roadmap.service.ts"
click node_simulado "https://github.com/jpavrdev/plataforma-estudos/blob/main/backend/src/services/simulado.service.ts"
click node_flashcards "https://github.com/jpavrdev/plataforma-estudos/blob/main/backend/src/services/flashcard.service.ts"
click node_stats "https://github.com/jpavrdev/plataforma-estudos/blob/main/backend/src/services/stats.service.ts"
click node_streak "https://github.com/jpavrdev/plataforma-estudos/blob/main/backend/src/services/streak.ts"
click node_database "https://github.com/jpavrdev/plataforma-estudos/blob/main/backend/schema.ts"
click node_dbclient "https://github.com/jpavrdev/plataforma-estudos/blob/main/backend/db.ts"
click node_runner "https://github.com/jpavrdev/plataforma-estudos/blob/main/runner/server.mjs"
click node_labs "https://github.com/jpavrdev/plataforma-estudos/blob/main/labs/server.mjs"
click node_labws "https://github.com/jpavrdev/plataforma-estudos/blob/main/backend/src/labs.ws.ts"
click node_ats "https://github.com/jpavrdev/plataforma-estudos/blob/main/backend/src/services/ats.service.ts"
click node_community "https://github.com/jpavrdev/plataforma-estudos/blob/main/backend/src/services/comunidade.service.ts"
click node_studio "https://github.com/jpavrdev/plataforma-estudos/blob/main/backend/src/services/estudio.service.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_webapp,node_authui,node_trailui,node_reviewui,node_homecontent,node_roadmap,node_simulado,node_flashcards toneBlue
class node_api,node_authroutes,node_trailroutes,node_trailcontroller,node_authcontroller,node_authschema,node_authmw,node_database,node_dbclient toneAmber
class node_stats,node_streak toneMint
class node_runner,node_labs,node_labws toneRose
class node_ats,node_community,node_studio,node_learner toneIndigo
```

## Components

### Learning experience

- [Web application](https://github.com/jpavrdev/plataforma-estudos/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Account session](https://github.com/jpavrdev/plataforma-estudos/blob/main/frontend/src/contexts/AuthContext.tsx): `frontend/src/contexts/AuthContext.tsx`
- [Trails and lessons](https://github.com/jpavrdev/plataforma-estudos/blob/main/frontend/src/pages/TrilhaDetalhe/index.tsx): `frontend/src/pages/TrilhaDetalhe/index.tsx`
- [Spaced review](https://github.com/jpavrdev/plataforma-estudos/blob/main/frontend/src/pages/Revisao/index.tsx): `frontend/src/pages/Revisao/index.tsx`
- [Home content](https://github.com/jpavrdev/plataforma-estudos/blob/main/frontend/src/data/home.ts): `frontend/src/data/home.ts`
- [Roadmap service](https://github.com/jpavrdev/plataforma-estudos/blob/main/backend/src/services/roadmap.service.ts): `backend/src/services/roadmap.service.ts`
- [Exam service](https://github.com/jpavrdev/plataforma-estudos/blob/main/backend/src/services/simulado.service.ts): `backend/src/services/simulado.service.ts`
- [Flashcard service](https://github.com/jpavrdev/plataforma-estudos/blob/main/backend/src/services/flashcard.service.ts): `backend/src/services/flashcard.service.ts`

### Platform API

- [HTTP API](https://github.com/jpavrdev/plataforma-estudos/blob/main/backend/app.ts): `backend/app.ts`
- [Authentication routes](https://github.com/jpavrdev/plataforma-estudos/blob/main/backend/src/routes/auth.routes.ts): `backend/src/routes/auth.routes.ts`
- [Trail routes](https://github.com/jpavrdev/plataforma-estudos/blob/main/backend/src/routes/trail.routes.ts): `backend/src/routes/trail.routes.ts`
- [Trail controller](https://github.com/jpavrdev/plataforma-estudos/blob/main/backend/src/controllers/TrailController.ts): `backend/src/controllers/TrailController.ts`
- [Authentication controller](https://github.com/jpavrdev/plataforma-estudos/blob/main/backend/src/controllers/AuthController.ts): `backend/src/controllers/AuthController.ts`
- [Auth validation](https://github.com/jpavrdev/plataforma-estudos/blob/main/backend/src/schemas/auth.schema.ts): `backend/src/schemas/auth.schema.ts`
- [Authentication middleware](https://github.com/jpavrdev/plataforma-estudos/blob/main/backend/src/middlewares/auth.ts): `backend/src/middlewares/auth.ts`
- [PostgreSQL data](https://github.com/jpavrdev/plataforma-estudos/blob/main/backend/schema.ts): `backend/schema.ts`
- [Database client](https://github.com/jpavrdev/plataforma-estudos/blob/main/backend/db.ts): `backend/db.ts`

### Progress and community

- [Progress statistics](https://github.com/jpavrdev/plataforma-estudos/blob/main/backend/src/services/stats.service.ts): `backend/src/services/stats.service.ts`
- [Study streak](https://github.com/jpavrdev/plataforma-estudos/blob/main/backend/src/services/streak.ts): `backend/src/services/streak.ts`

### Isolated execution

- [Challenge runner](https://github.com/jpavrdev/plataforma-estudos/blob/main/runner/server.mjs): `runner/server.mjs`
- [Linux labs](https://github.com/jpavrdev/plataforma-estudos/blob/main/labs/server.mjs): `labs/server.mjs`
- [Lab WebSocket](https://github.com/jpavrdev/plataforma-estudos/blob/main/backend/src/labs.ws.ts): `backend/src/labs.ws.ts`

### Administration and services

- [Resume analysis](https://github.com/jpavrdev/plataforma-estudos/blob/main/backend/src/services/ats.service.ts): `backend/src/services/ats.service.ts`
- [Community](https://github.com/jpavrdev/plataforma-estudos/blob/main/backend/src/services/comunidade.service.ts): `backend/src/services/comunidade.service.ts`
- [Content studio](https://github.com/jpavrdev/plataforma-estudos/blob/main/backend/src/services/estudio.service.ts): `backend/src/services/estudio.service.ts`

### Other components

- **Learner**

## Connections

- Learner → Web application: uses
- Web application → Account session: provides session (evidence: `frontend/src/App.tsx`)
- Web application → Trails and lessons: routes to (evidence: `frontend/src/App.tsx`)
- Web application → Spaced review: routes to (evidence: `frontend/src/App.tsx`)
- Web application → Home content: uses
- Trails and lessons → HTTP API: requests lessons
- Spaced review → HTTP API: requests cards
- Account session → HTTP API: requests session (evidence: `frontend/src/contexts/AuthContext.tsx`)
- HTTP API → Authentication routes: mounts (evidence: `backend/app.ts`)
- HTTP API → Trail routes: mounts (evidence: `backend/app.ts`)
- Authentication routes → Authentication controller: routes to (evidence: `backend/src/routes/auth.routes.ts`)
- Authentication routes → Authentication middleware: applies limits
- Authentication controller → Auth validation: validates with (evidence: `backend/src/controllers/AuthController.ts`)
- Trail routes → Authentication middleware: protects routes (evidence: `backend/src/routes/trail.routes.ts`)
- Trail routes → Trail controller: routes to (evidence: `backend/src/routes/trail.routes.ts`)
- Trail controller → Roadmap service: uses
- Trail controller → Content studio: uses (evidence: `backend/src/controllers/TrailController.ts`)
- Trail controller → Progress statistics: requests stats (evidence: `backend/src/controllers/TrailController.ts`)
- Authentication controller → PostgreSQL data: reads and writes (evidence: `backend/src/controllers/AuthController.ts`)
- Progress statistics → PostgreSQL data: queries (evidence: `backend/src/services/stats.service.ts`)
- Study streak → PostgreSQL data: queries
- Database client → PostgreSQL data: connects (evidence: `backend/db.ts`)
- HTTP API → Challenge runner: submits code
- HTTP API → Lab WebSocket: serves lab sockets
- Lab WebSocket → Linux labs: issues sessions
- HTTP API → Exam service: serves exams
- HTTP API → Flashcard service: serves review
- HTTP API → Resume analysis: serves resume analysis
- HTTP API → Community: serves community
- HTTP API → Study streak: calculates streak
