Developer OverviewΒΆ
Welcome to the OSCAR Bot developer documentation. This guide helps you understand, set up, and extend the bot.
Quick StartΒΆ
-
New Contributors ---
First time here? Start with the Setup Guide to get OSCAR running locally.
-
Architecture ---
Understand how the components fit together. View System Architecture
-
Database & Data ---
Learn about the SQLite schema and Data Models. View Database Schema
-
Administrators ---
Need to deploy or maintain? Admin Guide
High-Level ArchitectureΒΆ
OSCAR connects Discord users with University module data. For detailed component diagrams and data flows, see the Architecture Guide.
graph LR
%% --- STYLING ---
classDef user fill:#0068b4,stroke:#dfe0e2,stroke-width:2px,color:#ffffff,font-weight:bold;
classDef discord fill:#5865F2,stroke:#dfe0e2,stroke-width:2px,color:#ffffff,font-weight:bold;
classDef oscar fill:#5f6af0,stroke:#dfe0e2,stroke-width:3px,color:#ffffff,font-weight:bold;
classDef nextcloud fill:#0082c9,stroke:#dfe0e2,stroke-width:2px,color:#ffffff,font-weight:bold;
classDef database fill:#727378,stroke:#dfe0e2,stroke-width:2px,color:#ffffff,font-weight:bold;
%% --- NODES ---
User("Discord User"):::user
Discord("Discord API"):::discord
OSCAR("OSCAR Bot"):::oscar
%% Grouping data sources visually via positioning
Nextcloud("Nextcloud tables<br/>Module Data"):::nextcloud
Database("SQLite<br/>User Data & Cache"):::database
%% --- CONNECTIONS ---
%% Forward Flow
User -->|Command| Discord
Discord -->|Event| OSCAR
%% Data Retrieval (Parallel)
OSCAR <-->|Read/Write| Database
OSCAR <-->|Fetch Data| Nextcloud
%% Return Flow
OSCAR -->|Response| Discord
Discord -->|Result| User
%% --- LINK STYLES ---
linkStyle 0 stroke:#0068b4,stroke-width:2px,fill:none
linkStyle 1 stroke:#5865F2,stroke-width:2px,fill:none
linkStyle 2 stroke:#727378,stroke-width:2px,fill:none
linkStyle 3 stroke:#0082c9,stroke-width:2px,fill:none
linkStyle 4 stroke:#5f6af0,stroke-width:2px,fill:none
linkStyle 5 stroke:#5865F2,stroke-width:2px,fill:none
graph TB
subgraph System["OSCAR Discord Bot System"]
subgraph Frontend["Frontend Layer"]
Discord["Discord API<br/>Events & Interactions"]
end
subgraph Application["Application Layer"]
BotCore["Bot Core<br/>oscar.py"]
subgraph CommandLayer["Command Layer - Cogs"]
ModulCog["π Module Cog<br/>Search & Filter"]
AdminCog["π Admin Cog<br/>Feedback Review"]
HelpCog["β Help Cog<br/>Support"]
end
subgraph PresentationLayer["Presentation Layer - UI"]
Views["Views<br/>Start, Module, Feedback<br/>Semesterplan, Select"]
Components["Components<br/>Buttons, Selects<br/>Custom Elements"]
end
end
subgraph Business["Business Logic Layer"]
Filter["Filter Engine<br/>CP/SWS Filtering"]
Analytics["Analytics Engine<br/>Statistics & Plots"]
end
subgraph Data["Data Layer"]
Database["SQLite<br/>User Data & Cache"]
ModuleCache["Module Cache<br/>In Memory"]
end
subgraph Integration["Integration Layer"]
TableAPI["Tables API Client<br/>Nextcloud API"]
end
subgraph Resources["Resources & Config"]
i18n["i18n System<br/>Translations"]
Enums["Enums & Types<br/>LanguageCode<br/>StudyCourse"]
TypedDicts["TypedDicts<br/>Data Structures"]
end
end
Discord -->|Events| BotCore
BotCore -->|Routes Commands| CommandLayer
ModulCog -->|Creates| Views
AdminCog -->|Creates| Views
HelpCog -->|Creates| Views
Views -->|Contains| Components
Views -->|Reads| i18n
Views -->|Action| Database
ModulCog -->|Uses| Filter
Filter -->|Search| ModuleCache
ModuleCache -->|Fetch Raw| TableAPI
AdminCog -->|Uses| Analytics
Analytics -->|Visualize| Database
Analytics -->|Labels| i18n
Database -->|Stores| ModuleCache
Database -->|Validates| Enums
Database -->|Types| TypedDicts
Views -->|Respects| Enums
Views -->|Maps| TypedDicts
style System fill:#1e3a8a,color:#fff
style Frontend fill:#5f6af0,color:#fff
style Application fill:#4a9bc4,color:#fff
style CommandLayer fill:#5ab5e0,color:#000
style PresentationLayer fill:#6ac5e8,color:#000
style Business fill:#6b7280,color:#fff
style Data fill:#d4af37,color:#000
style Integration fill:#10b981,color:#fff
style Resources fill:#f59e0b,color:#000
Project StructureΒΆ
OSCAR is built using discord.py and structured into several key components:
discord-bot/
βββ src/
β βββ oscar/ # Bot core
β β βββ main.py # Entry point (sets up intents)
β β βββ oscar.py # Custom Bot class (auto-loads cogs)
β β β
β β βββ cogs/ # Command handlers
β β β βββ modul.py # /module, /filter, /semesterplan, /standard_plan
β β β βββ admin.py # /feedback_review (admin-only)
β β β βββ help.py # /help (with translations)
β β β βββ examples.py # /colors, /buttons (dev tools)
β β β
β β βββ ui/ # UI framework
β β βββ base_views.py # TranslatedView, CustomView
β β βββ all_info_view.py # Detailed module attributes view
β β βββ custom_view.py # Base class wrapper
β β βββ paginated_view.py # Pagination logic for long lists
β β βββ select_button.py # Selection UI components
β β βββ semesterplan_view.py # Semester planning interface
β β βββ translated_view.py # i18n-aware base view
β β βββ buttons.py # Reusable button components
β β βββ start_view.py # /start onboarding
β β βββ module_view.py # Module display card
β β βββ select_view.py # /filter interface
β β βββ feedback_view.py # /feedback form
β β
β βββ util/ # Helper modules
β βββ database.py # SQLite wrapper (singleton)
β βββ tables.py # Nextcloud API client
β βββ module.py # Module data model
β βββ translations.py # i18n dictionaries
β βββ enums.py # LanguageCode, StudyCourse
β βββ modules_filter.py # Filter logic (CP, SWS)
β βββ typed_dicts.py # Type definitions
β βββ plots.py # Matplotlib charts (feedback)
β
βββ docs/ # MkDocs documentation (this site)
βββ database/ # SQLite files (auto-created)
β βββ oscar.db # Main database
βββ .env # Environment config (YOU create)
βββ .gitlab-ci.yml # CI/CD pipeline
βββ pyproject.toml # Dependencies & metadata
βββ README.md # Project overview
Tech Stack & PrerequisitesΒΆ
We use pyproject.toml for dependency management.
Check pyproject.toml
[build-system]
requires = ["hatchling >= 1.27"]
build-backend = "hatchling.build"
[tool.hatch.build.targets.wheel]
packages = ["src/oscar", "src/util"]
# https://docs.basedpyright.com/latest/configuration/config-files/
[tool.basedpyright]
"typeCheckingMode" = "recommended"
# "reportUnusedFunction" = false
[tool.pylint]
# disable = "unused-function"
[tool.pylint.options]
good-names-rgx = "(_[a-z_]*|command|group|listen)"
[tool.pylint.messages_control]
disable = [
"C0114", # missing-module-docstring
"C0115", # missing-class-docstring
"C0116", # missing-function-docstring
"R0903", # too-few-public-methods
"W0511", # fixme (TODOs)
"R0801", # duplicate-code
]
[project.scripts]
oscar_ovgu = "oscar.main:main"
[project]
name = "oscar_ovgu"
version = "1.0.0"
authors = [
{ name="ISG", email="jana.goers@ovgu.de" },
]
description = "Organized Study Choice & Academic Roadmapper"
readme = "README.md"
requires-python = ">=3.12"
dependencies = [
"discord-py",
"python-dotenv",
"loguru",
"cyclopts",
"requests",
"rapidfuzz",
"translate",
"matplotlib>=3.9.4",
"numpy",
"toml"
]
classifiers = [
"Programming Language :: Python :: 3",
"Operating System :: OS Independent",
]
license = "Apache-2.0"
license-files = ["./license"]
[project.urls]
Homepage = "https://www.fin.ovgu.de/"
Issues = "https://www.fin.ovgu.de/Fakultaet.html"
[project.optional-dependencies]
dev = [
"pytest>=8.0.0",
"pytest-mock>=3.12.0",
"pytest-cov>=4.0.0",
"pylint>=3.0.0",
"pytest-asyncio>=0.23.0",
]
docs = [
"mkdocs-material>=9.6.20",
"mkdocstrings[python]>=0.30.1",
"mkdocs-glightbox",
"mkdocs-macros-plugin",
]
[tool.pytest.ini_options]
testpaths = ["tests"]
addopts = "-v --tb=short"
asyncio_mode = "auto"
filterwarnings = [
"ignore::DeprecationWarning:discord",
]
| Technology | Version | Purpose | Why this choice? |
|---|---|---|---|
| Python | 3.12+ | Language | Modern async/await, type hints, rich ecosystem |
| discord.py | Latest | Discord API | Most mature & actively maintained Discord library |
| SQLite | 3.x | Database | Zero-config, perfect for caching, ACID compliant |
| loguru | Latest | Logging | Structured logs, better DX than stdlib logging |
| matplotlib | 3.9+ | Visualization | Admin feedback charts (boxplot, timeline) |
| basedpyright | Latest | Type checking | Strict typing catches bugs at dev time |
| Nextcloud Tables | API v1 | Data source | Faculty's existing module management system | | MkDocs Material | Latest | Documentation | Beautiful, searchable, mobile-friendly |