Models
The diagrams you need, with one complete example
Agile does not revolve around models, but some of them add a lot and are part of the documentation. Every example comes from the same made-up app that complements Bicing with Open Data BCN data.
Conceptual model (UML class diagram)
The main concepts of the problem, independent of architecture and technology. Creative concepts of your own count, not just the ones in the open dataset.
UML: User, Trip, Station, Badge: User; email: String; name: String; joinedOn: Date; Trip; id: Natural; start: DateTime; end: DateTime; km: Real; Station; location: Coordinate; freeBikes: Natural; Badge; description: String; points: Natural; 1; *; makes ▸; origin; 0..1; destination; earns ▾; favourites; Integrity constraints; IC1. Keys: (User, email), (Station, id), (Trip, id); IC2. end > start; IC3. km >= 0; IC4. The destination, if any, differs from the origin; Comes from open data; New concept of the team.
Domain layer class diagram
The solution logic inside a three-layer architecture, with design patterns and operations already applied. Explain which patterns you use and why.
UML: Adapter: StationService; - cache: Station[*]; + nearby(p: Position): Station[*]; + refresh(); «interface»; StationSource; + getStations(): Station[*]; OpenDataBcnAdapter; CsvAdapter; FakeSource; 1; Adapter pattern: the domain does not depend on the open data format. Swapping the source (API, CSV, mock) leaves StationService untouched.
Physical diagram (architecture)
The nodes and subsystems: app, server, database, external services and the service you build for another team. A sketch at the inception that you refine every sprint.
Physical architecture: Flutter clients and team B through the FIB NAT, virtech VM with Docker (Nginx, Node.js, PostgreSQL, Redis), Open Data BCN, team C service, Firebase, GitHub Actions: Clients; External services; Mobile app; Flutter · Android · iOS; Admin web app; Flutter Web; Team B; consumes our service; Google Maps · Sign-In; SDKs inside the app; FIB NAT; nattech.fib.upc.edu; :40330 → VM :8080; Cloudflare Tunnel; HTTPS (optional); virtech · FIB; Ubuntu virtual machine · OpenNebula; Docker Compose; Nginx; :8080 · reverse proxy; REST API; Node.js + Express; :3000 · /api/v1 · /docs; Redis; cache and sessions; PostgreSQL + PostGIS; :5432; uploads/ volume; user images; GitHub Actions runner (self-hosted); git pull · docker compose up -d; No backups: everything must be rebuildable from GitHub; Open Data BCN; Bicing (GBFS) · JSON; Team C service; REST · we consume it; Firebase Cloud Messaging; push notifications; GitHub; front and back repos · CI; HTTP · JSON; SDK; :8080; /api; SQL; deploys; GET; REST; push; push notification; outbound:; the runner polls for jobs; request (HTTP, SQL); CI/CD and deployment; Each arrow points from the caller to the one it calls.
Component diagram (UML)
A simplified view of the whole system and of how its components relate.
UML component diagram: «subsystem» App; «UI» Map; «UI» Profile; :RestClient; «subsystem» REST API; :Stations; :Trips; :Authentication; «subsystem» External services; :Open Data BCN; :Team C service; /api/v1.
Database schema
A class diagram describing the schema. In relational databases, underline the primary key and put foreign keys in brackets (FK). In NoSQL, use composition for embedded documents and association for references.
Relational schema (PostgreSQL): user; PK; email VARCHAR; name VARCHAR; joinedOn DATE; trip; id SERIAL; FK; origin INT; destination INT NULL; start TIMESTAMP; end TIMESTAMP; km NUMERIC; station; id INT; geom GEOGRAPHY(Point); freeBikes INT; userbadge; date DATE; badge; description TEXT; points INT; primary key; foreign key →.
Common mistakes in the models
- Putting technology in the conceptual model (SQL types, auto-increment IDs, "Controller").
- Using an attribute where there should be an association (a
stationIdinside Trip). - Forgetting multiplicities or the textual integrity constraints.
- A model that copies the columns of the open dataset.
- Diagrams that are not updated when the code changes: it is part of the definition of done.
- Blurry screenshots: export to SVG or a high-resolution PNG.