This was a test of how well Opus can do mostly by itself.
The model used was Opus 4.5. The cost of the project in tokens was ~10$ to make the code, and ~$20 to review the code in a customer review loop (annotate -> fix -> annotate ... loop) The instructions were the instructions for the class project with some additional comments about the technology used.
The project was first planned out by the chat, and the plan is available in PLAN.md.
Everything outside of the section above was generated by an LLM.
A full-stack database application for managing prison operations, built as a project for the "Bazy Danych 2025" (Databases 2025) course.
- Prisoner Management: Track prisoners, their sentences, cell assignments, and release dates
- Cell & Block Management: Monitor cell occupancy, capacity, and security levels
- Staff Management: Manage prison staff roles and assignments
- Visit System: Schedule and track prisoner visits with visitor verification
- Rehabilitation Programs: Enroll prisoners in educational and rehabilitation programs
- Incident Tracking: Log and track security incidents
- Release Calculations: Automatic release date calculation with parole eligibility
| Component | Technology |
|---|---|
| Database | PostgreSQL 15 (Docker) |
| Backend | Python 3.11+ with FastAPI |
| Package Manager | UV |
| Frontend | Electron + HTML/CSS/JavaScript |
- Docker - for running PostgreSQL
- Python 3.11+ - for the backend
- UV - Python package manager (install)
- Node.js 18+ - for Electron frontend
# Clone the repository
git clone git@github.com:qbrak/example_chat_homework_databases.git
cd example_chat_homework_databases
# Start everything (database, backend, frontend)
./start.sh# Clone the repository
git clone git@github.com:qbrak/example_chat_homework_databases.git
cd example_chat_homework_databases
# Start everything
.\start.ps1start.bat- Starts PostgreSQL in a Docker container
- Waits for the database to be ready
- Initializes the schema, views, functions, and seed data
- Starts the FastAPI backend server
- Installs frontend dependencies and launches Electron
| Variable | Default | Description |
|---|---|---|
DB_HOST |
localhost |
Database host |
DB_PORT |
5432 |
Database port |
DB_NAME |
prison_management |
Database name |
DB_USER |
prison_admin |
Database user |
DB_PASSWORD |
required | Database password |
CORS_ORIGINS |
http://localhost:* |
Allowed CORS origins (comma-separated) |
API_URL |
http://localhost:8000 |
Backend API URL (for frontend) |
To drop all data and recreate the database with fresh seed data:
# Linux/macOS
./reset_database.sh
# Windows PowerShell
.\reset_database.ps1
# Windows CMD
reset_database.batpiotrek/
├── database/
│ ├── 01_schema.sql # Tables and constraints
│ ├── 02_views.sql # Database views
│ ├── 03_functions.sql # Functions and triggers
│ └── 04_seed_data.sql # Sample data (50+ prisoners)
├── backend/
│ ├── server.py # FastAPI application
│ └── pyproject.toml # Python dependencies
├── frontend/
│ ├── main.js # Electron main process
│ ├── preload.js # Electron preload script
│ ├── index.html # Main HTML
│ ├── renderer/
│ │ ├── app.js # Frontend application logic
│ │ └── styles.css # Styling
│ └── package.json # Node dependencies
├── start.sh # Unix startup script
├── start.bat # Windows CMD startup script
├── start.ps1 # Windows PowerShell startup script
├── reset_database.sh # Unix database reset
├── reset_database.bat # Windows CMD database reset
└── reset_database.ps1 # Windows PowerShell database reset
| Table | Description |
|---|---|
crime_types |
Enumeration of crime categories |
staff_roles |
Enumeration of staff positions |
program_types |
Enumeration of rehabilitation programs |
cell_blocks |
Prison blocks with security levels |
cells |
Individual cells with capacity |
staff |
Prison employees |
prisoners |
Prisoner records |
sentences |
Sentence details with parole info |
visitors |
Registered visitors |
visits |
Visit records |
programs |
Available rehabilitation programs |
prisoner_programs |
Program enrollments (many-to-many) |
incidents |
Security incidents |
v_prisoner_details- Complete prisoner info with cell and sentencev_cell_occupancy- Cell status with current/max occupancyv_upcoming_releases- Prisoners releasing within 30 daysv_block_summary- Block statistics (occupancy, incidents)v_staff_overview- Staff by role and block assignment
calculate_release_date()- Computes release date from sentenceget_prisoner_full_history()- Returns prisoner's complete recordget_cell_occupancy()- Returns occupancy for a specific celltransfer_prisoner()- Safely transfers prisoner between cellstrg_check_cell_capacity- Prevents cell overcrowdingtrg_check_visitor_blacklist- Blocks blacklisted visitorstrg_update_timestamp- Auto-updatesupdated_atcolumns
GET /prisoners- List all prisonersGET /prisoners/{id}- Get prisoner detailsPOST /prisoners- Add new prisonerPUT /prisoners/{id}- Update prisonerDELETE /prisoners/{id}- Delete prisoner
GET /views/{view_name}- Query database viewsprisoner_detailscell_occupancyupcoming_releasesblock_summarystaff_overview
GET /cells- List cellsGET /staff- List staffGET /visitors- List visitorsGET /visits- List visitsGET /programs- List programsGET /incidents- List incidents
| Requirement | Implementation |
|---|---|
| 10-12 tables | 13 tables |
| Integrity constraints | CHECK, NOT NULL, UNIQUE, FK |
| 1-to-many relationships | prisoners-sentences, cells-prisoners |
| Many-to-many relationships | prisoner_programs |
| Foreign key actions | CASCADE, RESTRICT, SET NULL |
| Enumeration tables | crime_types, staff_roles, program_types |
| 2+ functions/triggers | 4 functions, 3 triggers |
| 2+ non-trivial views | 5 views |
| GUI without SQL | Electron desktop app |
| CRUD operations | Full support via API |
| Pre-populated data | 50 prisoners, 100+ visits, etc. |
This project was created for educational purposes as part of the Databases 2025 course.