Project structure · More
Discord bot project structure
Opens with creditsA study buddy bot for Discord servers (focus sessions, streaks, a leaderboard), built on discord.js with TypeScript from the official create-discord-bot template. Node runs the TypeScript directly, commands and events are one file each in folders the loaders read, and the bot grows a PostgreSQL database with Drizzle, background jobs and a Docker deploy. For students who have made a /ping bot and want one that survives thousands of servers.
How it grows
Each stage opens the explorer there
- 1Day 1What the scaffold and your first hour give you28 files and folders
- 2GrowingWhat a real app with features and tests adds+55 files and folders
- ProductionWhat running it for real users adds+25 files and foldersOpens with credits
- ExpertWhat a team needs to keep it healthy for years+24 files and foldersOpens with credits
How it is organised
- One file per command, one per event, one per component prefix. Loaders find them, so adding a feature never means editing a central switch.
- Command files are thin: read options, call a service, reply. Services hold the rules and never import Discord types, so they are testable without Discord.
- Reply within 3 seconds or defer. Anything slow happens after `deferReply()`.
- Ask for the fewest intents and permissions that work. Slash commands need no privileged intents at all.
- Every server's data lives in PostgreSQL keyed by guild id, never in memory or JSON files. Discord ids are strings.
- Register commands only when their definitions change, to a test server while developing and globally on release.
- The token is the bot. It lives only in environment variables and secret stores, and you rotate it the moment it might have leaked.
At the top of the project
Open one in the explorer for the full story
- study-buddy/
- .git/Git history, created by `git init`.
- .vscode/Editor settings and recommended extensions from the template.2 inside
- drizzle/SQL migrations generated by `drizzle-kit generate` from db/schema.ts.2 inside
- node_modules/Installed packages.
- src/All bot code. Node 24 runs these TypeScript files directly, no build step.11 inside
- tests/Vitest tests: services against a real PostgreSQL, commands with fake interactions.5 inside
- .envYour bot token and application id, read by `node --env-file=.env`.
- .env.exampleEvery variable name with empty or fake values, committed for teammates.
- .gitignoreNode's standard ignore list: logs, node_modules, coverage, caches.
- .nvmrcPins Node 24, which the template requires (`engines: >=24.17.0`).
- .prettierignoreFiles Prettier skips.
- .prettierrc.jsonPrettier settings from the template (tabs, single quotes, wide lines).
- compose.yamlDocker Compose: PostgreSQL for development, and the bot itself to test the production image.
- drizzle.config.tsdrizzle-kit settings: schema path, migrations folder, PostgreSQL dialect, database URL.
- eslint.config.jsESLint flat config using eslint-config-neon, the discord.js team's shared rules.
- package-lock.jsonExact versions of every package, written by npm install.
- package.jsonScripts (start, deploy, lint, format), dependencies, `"type": "module"` and the Node engine.
- README.mdWhat the bot does, the invite link, how to run it locally and how to deploy.
- tsconfig.eslint.jsonExtends tsconfig.json and includes config files, so ESLint can type check them too.
- tsconfig.jsonStrict TypeScript settings for type checking only: `noEmit`, `erasableSyntaxOnly`, bundler resolution.
- vitest.config.tsVitest settings: test folders, a global setup that migrates the test database.
Learn more on Sefism
Roadmaps, cheat sheets and projects that go with Discord bot.
- Roadmap· Node.jsBackend development roadmapAPIs, databases, auth, deploys
- Roadmap· PostgreSQLSQL and databases roadmapQueries, design, indexes, transactions
- RoadmapAutomation for clients roadmapWorkflows with n8n, Make or Zapier
- RoadmapDevOps and cloud roadmapLinux, Docker, Kubernetes, AWS
- Cheat sheetBackend development cheat sheetAPIs, databases, auth, deploys.
- Cheat sheetSQL and databases cheat sheetQueries, design, indexes, transactions.
- Cheat sheetAutomation for clients cheat sheetWorkflows with n8n, Make or Zapier.
- Cheat sheetDevOps and cloud cheat sheetLinux, Docker, Kubernetes, AWS.
- FYP idea· IntermediateTeam Chat App with Threads and Read Receipts on MongoDBBuild a Slack-style team chat for university societies and student project groups, with channels, threaded replies, read receipts, unread counts and live updates. The point is the MongoDB modelling: where to embed and where to reference messages and threads, change streams for real-time delivery, and pagination that stays fast as channels grow.
See 11 moreShow fewer
- FYP idea· IntermediateCompetitive Programming Training Tracker for University Clubs and ICPC CoachesBuild a training dashboard for a university competitive programming club: members link their Codeforces handles, and coaches see contest history, rating trends, upsolving backlogs, topic coverage by problem tag and team practice results in one place. It uses the official Codeforces API, turns raw submissions into training signals, and helps a club prepare ICPC teams without spreadsheets.
- FYP idea· IntermediateRaast Merchant Payments Integration Kit with Dynamic QR, Request to Pay and ReconciliationPakistan's Raast instant payment system supports merchant payments by QR code, alias and request to pay, but small businesses and developers struggle to connect it to their shops and invoices. Build an open integration kit: a simulated payment service provider API modelled on Raast's person-to-merchant flows, a merchant dashboard, dynamic QR generation per order, request-to-pay links and automatic reconciliation of payments to orders. Design it so a real provider's API could replace the simulator later.
- QuestionWhat projects should I build in my first year of university?Build small, finished projects that solve problems you or people around you actually have: a script that automates a chore, a command line tool, a simple website for a society or family business. First year is about finishing things and using Git, not about impressive ideas.
- QuestionShould I use PostgreSQL or MongoDB for my project?For most student and startup projects, PostgreSQL is the safer default: relational data, joins, constraints and transactions fit most apps, and it handles JSON and vector search too. MongoDB is a good fit when your data is naturally document-shaped and varies a lot, or your team already knows it well. Model your data first, then choose.
- QuestionDo I need Docker and Kubernetes as a junior developer?Docker, yes: learn the basics, because nearly every team uses containers and you will be expected to run the project locally and read a Dockerfile. Kubernetes, mostly no: understand what it does and a few core terms, but deep Kubernetes can wait until your job or a DevOps direction needs it.
- QuestionWhat does proof of work mean for a fresher developer?Proof of work is evidence someone can check in a few minutes that you can do the job: a deployed project real people could use, readable code with tests, a pull request merged into someone else's project, or a clear write-up of a problem you solved. It replaces the experience a fresher does not have yet, so it must be easy to find and easy to verify.
- Resource· GuideNode.js LearnThe official Node.js Learn guides explain what Node itself is doing underneath your framework: the event loop, asynchronous work, files and streams, HTTP, environment variables, running TypeScript, diagnostics and the built-in test runner. The articles are short and free. They suit JavaScript developers who use Express, Next.js or another tool but want to understand the runtime, and anyone debugging a problem that a framework tutorial glosses over.
- Resource· GuideThe TypeScript HandbookThe TypeScript Handbook is the official, free guide to TypeScript's type system from the TypeScript team, written for working programmers and kept current with each release. It covers everyday types, narrowing, functions, object types, generics, type manipulation, classes and modules, and it is designed to be read in a few hours. It suits JavaScript developers adopting TypeScript and anyone who writes types by copying patterns without understanding them.
- Resource· GuidePostgreSQL DocumentationThe official PostgreSQL manual for the current release: a tutorial, the full SQL language reference, every data type and function, server administration, and chapters on indexes, EXPLAIN and concurrency control. It is accurate, well written and the place to check any PostgreSQL behaviour before trusting a blog post.
- Resource· GuideDocker Docs: Get StartedDocker's official starting point: install Docker, follow a tutorial that builds, runs and shares a containerised application, then work through short concept pages on containers, images, registries, Compose, image layers, Dockerfiles, the build cache, multi-stage builds, ports and persistent data. It suits developers who have heard of containers but never used them, and it is current, free and more accurate than most tutorials copied from it.
- Resource· GuideVitest DocumentationThe official documentation for Vitest, the test runner built on Vite. Its getting started guide has you writing and running a real test in minutes, then covers matchers, async tests, setup and teardown, mocking (functions, modules, timers, dates, requests), snapshots, coverage, the UI dashboard and browser mode for component tests. It uses a Jest-compatible API, so it suits JavaScript and TypeScript developers starting to test, and teams moving from Jest.
Checked against 16 official sources, October 2026. If something has changed, the docs win.Show sourcesHide sources
- create-discord-bot (official template)
- TypeScript template files
- discord.js Guide
- discord.js documentation
- Discord: Gateway intents
- Discord: Application commands
- Discord: Receiving and responding to interactions
- Discord: Rate limits
- Discord: Sharding
- Discord Developer Policy
- Node.js: Running TypeScript natively
- Drizzle ORM: PostgreSQL get started
- Drizzle ORM: Migrations
- Docker: Containerize a Node.js application
- Testcontainers for Node.js: PostgreSQL module
- Vitest documentation
Best practices and checklists for this stack
Picked from the other libraries by shared topics.
Best practices
See all- Node.js API Best PracticesBuild Node.js REST APIs that hold up in production: structure, validation, error handling, security headers, rate limits, logging, testing and graceful shutdown.
- Observability Best PracticesKnow when production is hurting users and why: SLOs, golden signals, metric naming and cardinality, structured logs, OpenTelemetry traces and burn-rate alerts.
- PostgreSQL Best PracticesDesign, index, query and run PostgreSQL well: data types, constraints, EXPLAIN, zero-downtime migrations, pooling, transactions, backups and roles.
Checklists
See all- Database Migration ChecklistCheck a schema or data migration before it ships: expand and contract, lock behaviour, online indexes, batched backfills, rehearsal on real data, backups, rollback, deploy order and monitoring.
- Production Readiness ChecklistCheck a service before it takes real traffic: ownership, SLOs, capacity, timeouts and retries, alerts, rollout and rollback, backups, security and on-call.
- API Security ChecklistCheck your REST or GraphQL API against the OWASP API Security Top 10: authentication, object authorization, rate limits, input validation, SSRF, CORS and logging.
Stuck on something specific?
Writing only gets you so far. If you want an answer to your situation rather than the general case, book a session and we will work through it together. Sessions are free for approved Sefism members, and a few slots open each week.
- 1:1 Mentorship
- Fresh Graduate Mentorship
- Career Guidance
Brand deals, promos and partnerships: tauseeffayyaz@gmail.com