An API dedicated to learning via the Leitner flashcard system. This project is built with a focus on Clean Code, Hexagonal Architecture, and Domain-Driven Design (DDD) principles.
The project follows the Hexagonal Architecture (Ports & Adapters) to isolate the business logic from external concerns.
src/
├── domain/ # Business Logic (Entities, Repositories Interfaces)
├── application/ # Use Cases (Orchestration)
├── adapters/ # Interface Adapters (Controllers, Implementations)
└── infrastructure/ # Frameworks & Drivers (Express, Database, UI)
- Runtime: Node.js (v20+)
- Language: TypeScript
- Framework: Express.js
- Database: PostgreSQL
- ORM: Prisma
- Testing: Vitest
- Containerization: Docker & Docker Compose
- Node.js & npm/pnpm/yarn
- Docker & Docker Compose (for the database)
- Clone the repository
- Install dependencies:
npm install
- Environment Setup:
Copy
.env.example(if available) or create a.envfile based on the variable used inload-env.tsanddocker-compose.yml.DATABASE_URL="postgresql://postgres:postgres@localhost:5432/postgres?schema=public"
Start the PostgreSQL container:
docker-compose up -dEnsure the database schema is up to date and populated with initial data:
# Generate Prisma Client
npm run prisma:generate
# Run Migrations
npm run prisma:migrate
# Seed Data (Optional)
npm run prisma:seed-
Development Mode (with hot reload):
npm run dev
-
Production Build:
npm run build npm start
Run unit and integration tests using Vitest:
npm testYou can explore the API endpoints using the Bruno collection provided in the bruno-collection/ directory.