Enterprise-grade backend foundation for the SOCS cybersecurity platform, built with Node.js, Express.js, Prisma ORM, and MariaDB.
This backend follows a layered structure so responsibilities stay clean as the product grows:
routes/: endpoint wiring onlycontrollers/: request and response mappingservices/: business workflows and authorization-sensitive logicrepositories/: Prisma-based database accessmiddleware/: cross-cutting concerns like auth, validation, sanitization, and error handlingvalidators/: Zod schemas for every public input surfaceconfig/: environment, Prisma, and rate-limiting setuputils/andconstants/: shared primitives
The current folder layout is a strong single-service base, while keeping boundaries clean enough to evolve into a larger monorepo later, for example:
apps/
backend/
packages/
shared-config/
shared-types/
shared-clients/
SOCS_backend/
├── prisma/
│ └── schema.prisma
├── src/
│ ├── config/
│ ├── constants/
│ ├── controllers/
│ ├── middleware/
│ ├── repositories/
│ ├── routes/
│ ├── services/
│ ├── utils/
│ ├── validators/
│ └── app.js
├── .env.example
├── package.json
├── README.md
└── server.js
- JWT authentication with
7dexpiry bcryptjspassword hashing- Role-based access control with
USERandADMIN - Prisma ORM on MariaDB
- Fully dynamic REST operations for all Core entities (Projects, Events, Team, Resources, Visuals)
- Pagination, filtering, and deep search capabilities
- Audit logging for login attempts, registration, contact submissions, and admin actions (e.g., entity mutations)
- Rate limiting on auth endpoints
- Helmet, CORS, compression, and request sanitization
- Centralized error handling and structured console logging
User: Standard user and admin accountsProject: Open-source intelligence and projectsEvent: Upcoming and past society workflows/eventsTeamMember: Core nodes/operators of the society (Supports fetching by UUID or friendly slug)Resource: Actionable intelligence links, tools, and writeupsVisual: Dynamic visual asset storage records for the GalleryContact: Inquiries and communication mappingAuditLog: Action tracking for network admins
ADMIN accounts should be provisioned through a seed script, database operation, or controlled internal admin workflow. Public registration creates USER accounts only.
- Create the database in MariaDB.
- Copy
.env.exampleto.envand fill in your values. - Install dependencies:
npm install- Generate Prisma client:
npx prisma generate- Run migrations to initialize the schema:
npx prisma migrate dev --name init- Start the server (Dev Mode runs on port 5001):
npm run devPORT=5001
DATABASE_URL="mysql://root:password@localhost:3306/socs_db"
JWT_SECRET=replace_with_a_long_random_secret
JWT_EXPIRES_IN=7d
NODE_ENV=development
CORS_ORIGIN=http://localhost:3000POST /api/auth/registerPOST /api/auth/loginGET /api/auth/me
All entities support robust querying, filtering, and secure mutation layers. Note: POST, PUT, and DELETE exclusively require an <admin_token> Bearer flag.
Projects
GET /api/projectsGET /api/projects/:idPOST /api/projectsPUT /api/projects/:idDELETE /api/projects/:id
Events
GET /api/eventsGET /api/events/:idPOST /api/eventsPUT /api/events/:idDELETE /api/events/:id
Team (Nodes)
GET /api/teamGET /api/team/:id(accepts UUID or unique operator slug!)POST /api/teamPUT /api/team/:idDELETE /api/team/:id
Resources
GET /api/resourcesGET /api/resources/:idPOST /api/resourcesPUT /api/resources/:idDELETE /api/resources/:id
Visuals (Gallery)
GET /api/visualsGET /api/visuals/:idPOST /api/visualsPUT /api/visuals/:idDELETE /api/visuals/:id
Contacts
POST /api/contacts
curl -X POST http://localhost:5001/api/auth/register \
-H "Content-Type: application/json" \
-d '{
"name": "Abhishek",
"email": "abhishek@socs.network",
"password": "StrongPass123"
}'curl -X POST http://localhost:5001/api/projects \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <admin_token>" \
-d '{
"title": "Threat Intel Portal",
"description": "Internal SOC dashboard for threat intelligence workflows.",
"techStack": ["Node.js", "Express", "MariaDB", "Prisma"],
"githubLink": "https://github.com/example/threat-intel-portal"
}'curl -X POST http://localhost:5001/api/team \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <admin_token>" \
-d '{
"slug": "abhishek",
"name": "Abhishek",
"role": "Frontend Architect",
"tier": "Admin",
"skills": ["React/Next.js", "Node.js", "Cyber Security", "UI/UX Design"]
}'curl "http://localhost:5001/api/resources?page=1&limit=10&category=roadmap"- Add seed scripts for initial admin creation and demo data.
- Add integration tests with a dedicated test database (e.g. Jest with SQLite).
- Introduce refresh tokens and token revocation for multi-device session control protocols.
- Add OpenAPI/Swagger documentation for frontend and partner integration.