Skip to content

manikandareas/CodiLeapServer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚀 Codileap Server

📁 Project Structure

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

🛠️ Dependencies

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.

📝 Setup Guide

Step 1: Clone the repository

git clone https://github.com/your-username/your-project.git

Step 2: Install dependencies

cd your-project
bun install

Step 3: Set up the database

Generate database schema and apply migrations:

bun run db:generate
bun run db:migrate

Step 4: Configure environment variables

Create a .env file in the project root with the following:

DATABASE_URL=postgres://username:password@localhost:5432/your_database

Step 5: Start the development server

bun run dev

Step 6: Access the database using Drizzle Studio

bun run db:studio

🔑 Key Features and Details

📋 Database Models

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.

🌐 Routes

The routes are implemented in the src/routes directory. Each route handles a specific module of the application (e.g., analytics, courses, badges).

HTTP Methods Used

  • GET: 📥 Retrieve resources.
  • POST: ✏️ Create new resources.
  • PUT: 🔄 Update existing resources.
  • DELETE: ❌ Remove resources.

Example Route

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

Services manage business logic and interact with the database. They act as a bridge between routes and models.

Example Service

import { db } from '../core/db';

export const analyticsService = {
  async getAll() {
    return db.analytics.findMany();
  },
};

📌 Notes

  • 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.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published