This repository contains a modular and scalable REST API built using Node.js, Express, and SQLite. The project follows a clean architecture with controllers, services, models, middleware, and route separation.
GitHub Repository: https://github.com/adithyareddym105-gif/API
- Secure API architecture
- API key authentication middleware
- Centralized logging
- SQLite database with schema + automatic seeding
- Modular service and controller layers
- User management API
- Video Game API (CRUD operations)
src/
├── config/
│ ├── config.js # Loads environment variables
│ └── database.js # SQLite database setup + seeding
│
├── controllers/
│ ├── userController.js
│ └── videoGameController.js ← NEW
│
├── middleware/
│ ├── apiKey.js
│ └── logger.js
│
├── models/
│ ├── User.js
│ └── VideoGame.js ← NEW
│
├── routes/
│ ├── userRoutes.js
│ └── videoGameRoutes.js ← NEW
│
├── services/
│ ├── userService.js
│ └── videoGameService.js ← NEW
│
└── index.js # Server entry point
git clone https://github.com/adithyareddym105-gif/API
cd APInpm installAPI_KEY=your_api_key_here
PORT=3000
npm startThe server will start on http://localhost:3000.
The API uses SQLite. The database is automatically created and seeded when the server starts.
You can find the database file in:
src/database.sqlite
Validates incoming requests using an API key.
Logs request method, endpoint, and response time.
Base URL: /users
| Method | Endpoint | Description |
|---|---|---|
| GET | / |
Get all users |
| GET | /:id |
Get user by ID |
| POST | / |
Create new user |
| PUT | /:id |
Update user |
| DELETE | /:id |
Delete user |
Base URL: /videogames
| Method | Endpoint | Description |
|---|---|---|
| GET | / |
Get all video games |
| GET | /:id |
Get video game by ID |
| POST | / |
Add new video game |
| PUT | /:id |
Update video game |
| DELETE | /:id |
Delete video game |
The project is structured using a clear separation of concerns:
- Controllers: Handle request/response
- Services: Business logic
- Models: Database structure
- Routes: API endpoints
- Middleware: Security + logs
- Config: Environment + DB setup
This makes the API easy to maintain, scale, and test.
This project is open-source and free to use.
Pull requests are welcome! Feel free to open an issue for suggestions or bugs.
If you like this project, consider giving it a star on GitHub!