src/
├── core/
│ ├── db/
│ ├── models/
│ │ ├── analytics_models.ts
│ │ ├── api_model.ts
│ │ ├── auth_models.ts
│ │ ├── badge_model.ts
│ │ ├── course_model.ts
│ │ ├── courses_model.ts
│ │ └── learning_path_models.ts
│ └── utils/
│ ├── jwts.ts
│ └── middlewares/
│ ├── auth_middleware.ts
│ └── error_validation_parser.ts
├── routes/
│ ├── analytics_route.ts
│ ├── auth_route.ts
│ ├── badge_route.ts
│ ├── course_route.ts
│ ├── index_route.ts
│ ├── learning_path_route.ts
│ ├── progress_route.ts
│ ├── quiz_route.ts
│ └── virtual_asisten_route.ts
├── services/
│ ├── analytics_service.ts
│ ├── auth_service.ts
│ ├── badge_service.ts
│ ├── course_service.ts
│ ├── learning_path_service.ts
│ ├── progress_service.ts
│ ├── quiz_service.ts
│ └── virtual_asistan_service.ts
├── index.ts
├── .gitignore
├── README.md
├── bun.lockb
├── drizzle.config.ts
├── package.json
└── tsconfig.json
This project leverages the following technologies:
- Bun: ⚡ A fast all-in-one JavaScript runtime optimized for speed.
- Postgres: 🐘 A robust relational database system.
- Drizzle ORM: 🌱 A type-safe ORM for TypeScript with a focus on simplicity and power.
- Hono JS: 🕊️ A minimalist web framework for building fast and scalable web applications.
git clone https://github.com/your-username/your-project.git
cd your-project
bun install
Generate database schema and apply migrations:
bun run db:generate
bun run db:migrate
Create a .env
file in the project root with the following:
DATABASE_URL=postgres://username:password@localhost:5432/your_database
bun run dev
bun run db:studio
The database models are defined in core/db
using Drizzle ORM.
-
Zod Validation: 🛡️ Models incorporate Zod to validate schema consistency. This ensures that only valid data can be persisted into the database.
-
Schema Example:
import { z } from 'zod'; const UserSchema = z.object({ id: z.string(), email: z.string().email(), password: z.string().min(8), createdAt: z.date(), }); export type User = z.infer<typeof UserSchema>;
This model is enforced across the application for type safety and validation.
The routes are implemented in the src/routes
directory. Each route handles a specific module of the application (e.g., analytics, courses, badges).
GET
: 📥 Retrieve resources.POST
: ✏️ Create new resources.PUT
: 🔄 Update existing resources.DELETE
: ❌ Remove resources.
import { Hono } from 'hono';
const app = new Hono();
app.get('/analytics', async (ctx) => {
const data = await analyticsService.getAll();
return ctx.json(data);
});
export default app;
Services manage business logic and interact with the database. They act as a bridge between routes and models.
import { db } from '../core/db';
export const analyticsService = {
async getAll() {
return db.analytics.findMany();
},
};
- This project uses Bun v1.1.34 and was initialized with
bun init
. - Make sure your PostgreSQL server is running before starting the application.
For questions or issues, feel free to raise an issue in the GitHub repository or contact the project maintainer.