How marcolinolucas/ecoleta-api works
Main Components
a. External Layer:
• Client Applications (Web & Mobile)
• File Storage System (for uploads)
• Database (SQLite3)
b. API Layer Components:
• Server (Express.js)
• Routes Layer
• Controllers Layer
• Database Layer
• Middleware Layer
• Validation Layer
Detailed Architecture Breakdown
[Client Layer]
• ▼
[API Gateway Layer]
[Middleware Layer] ─────────────┐
[Routes Layer] │
[Validation Layer] ────────┐ │
[Controllers Layer] │ │
[Database Layer] ◄────────┘ │
[File Storage] ◄────────────┘
Component Details
a. Routes Layer (src/routes/):
• itemsRoutes
• pointsRoutes
b. Controllers Layer (src/controllers/):
• ItemsController
• PointsController
c. Database Layer (src/database/):
• Migrations
• Seeds
• Connection
d. Validation Layer (src/validators/):
• itemsValidator
• pointsValidator
Important Flows to Highlight
a. Authentication Flow:
• Request → Middleware → Validation → Controller → Response
b. Data Flow:
• Controller → Database → Response
• File Upload → Multer → Storage → Database Reference
Technical Stack Callouts
• Node.js + TypeScript
• Express.js framework
• Knex.js Query Builder
• SQLite3 Database
• Jest Testing Framework
• Multer File Handling
Additional Elements
• Error handling flows
• Environment configuration
• Testing boundaries
• Where TypeScript interfaces are used
This architecture represents a typical MVC pattern with additional layers for validation and middleware, which is appropriate for this type of API service.