# petersolution/apipython architecture

> Architecture diagram of the GitHub repository petersolution/apipython, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/petersolution/apipython
- Repository: https://github.com/petersolution/apipython

## Overview

BackendFlask is a Flask attendance and work-entry service: clients manage users, record entries, query entry history and daily first-entry data, and access entry images and consecutive-entry counts. The shown user and entry routes dispatch to command/query handlers; those handlers access SQLAlchemy models, while the server initializes the database and registers route blueprints. The tree indicates additional image and entries-in-row capabilities, but their route wiring and handler behavior are not shown in the excerpts.

Main entry points: [`commands/__init__.py`](https://github.com/petersolution/apipython/blob/master/commands/__init__.py) (Command dispatcher), [`queries/__init__.py`](https://github.com/petersolution/apipython/blob/master/queries/__init__.py) (Query dispatcher), [`Server.py`](https://github.com/petersolution/apipython/blob/master/Server.py) (Flask server), [`routes/userRoutes.py`](https://github.com/petersolution/apipython/blob/master/routes/userRoutes.py) (User routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and application"]
  node_app["Flask server<br/>[Server.py]"]
  node_user_routes["User routes<br/>[userRoutes.py]"]
  node_entry_routes["Entry routes<br/>[entriesRoutes.py]"]
  node_row_routes["Entry-row routes"]
  node_image_routes["Image routes<br/>[ImagePatchRoute.py]"]
end

subgraph group_dispatch["Command and query dispatch"]
  node_command_dispatcher["Command dispatcher<br/>[__init__.py]"]
  node_query_dispatcher["Query dispatcher<br/>[__init__.py]"]
end

subgraph group_domain["Attendance domain"]
  node_user_commands["User commands"]
  node_entry_commands["Entry commands<br/>[Create_entry.py]"]
  node_row_commands["Entry-row commands"]
  node_image_commands["Image commands"]
  node_user_queries["User queries"]
  node_entry_queries["Entry queries"]
  node_row_queries["Entry-row queries"]
  node_image_queries["Image queries"]
end

subgraph group_persistence["Persistence models"]
  node_user_model["User model<br/>[user.py]"]
  node_entry_model["Entry model<br/>[entryModel.py]"]
  node_row_model["Entry-row model"]
  node_image_model["Image model<br/>[imageModel.py]"]
  node_database[("SQL database")]
end

subgraph group_client["Client"]
  node_react_client["User management UI<br/>[App.js]"]
end

node_user(("User"))

node_app -->|"registers"| node_user_routes
node_app -->|"registers"| node_entry_routes
node_app -->|"registers"| node_row_routes
node_app -->|"registers"| node_image_routes
node_app -->|"initializes"| node_database
node_user -->|"requests"| node_user_routes
node_user_routes -->|"dispatches queries"| node_query_dispatcher
node_user_routes -->|"dispatches commands"| node_command_dispatcher
node_entry_routes -->|"dispatches queries"| node_query_dispatcher
node_entry_routes -->|"dispatches commands"| node_command_dispatcher
node_query_dispatcher -->|"invokes handler"| node_user_queries
node_query_dispatcher -->|"invokes handler"| node_entry_queries
node_query_dispatcher -->|"invokes handler"| node_row_queries
node_query_dispatcher -->|"invokes handler"| node_image_queries
node_command_dispatcher -->|"invokes handler"| node_user_commands
node_command_dispatcher -->|"invokes handler"| node_entry_commands
node_command_dispatcher -->|"invokes handler"| node_row_commands
node_command_dispatcher -->|"invokes handler"| node_image_commands
node_user_commands -->|"reads and writes"| node_user_model
node_user_queries -->|"queries"| node_user_model
node_entry_queries -->|"queries"| node_entry_model
node_row_commands -->|"reads and writes"| node_row_model
node_row_commands -->|"queries"| node_entry_model
node_row_commands -->|"queries"| node_user_model
node_entry_model -->|"persists in"| node_database
node_user_model -->|"persists in"| node_database
node_row_model -->|"persists in"| node_database
node_image_model -->|"persists in"| node_database
node_react_client -.->|"calls user API"| node_user_routes

click node_app "https://github.com/petersolution/apipython/blob/master/Server.py"
click node_user_routes "https://github.com/petersolution/apipython/blob/master/routes/userRoutes.py"
click node_entry_routes "https://github.com/petersolution/apipython/blob/master/routes/entriesRoutes.py"
click node_row_routes "https://github.com/petersolution/apipython/blob/master/routes/entriesInRowRoute.py"
click node_image_routes "https://github.com/petersolution/apipython/blob/master/routes/ImagePatchRoute.py"
click node_command_dispatcher "https://github.com/petersolution/apipython/blob/master/commands/__init__.py"
click node_query_dispatcher "https://github.com/petersolution/apipython/blob/master/queries/__init__.py"
click node_user_commands "https://github.com/petersolution/apipython/tree/master/commands/handlers"
click node_entry_commands "https://github.com/petersolution/apipython/blob/master/commands/handlers/Create_entry.py"
click node_row_commands "https://github.com/petersolution/apipython/tree/master/commands/handlers/EntriesInRow"
click node_image_commands "https://github.com/petersolution/apipython/tree/master/commands/handlers/Images"
click node_user_queries "https://github.com/petersolution/apipython/tree/master/queries/handlers"
click node_entry_queries "https://github.com/petersolution/apipython/tree/master/queries/handlers"
click node_row_queries "https://github.com/petersolution/apipython/tree/master/queries/handlers/EntriesInRow"
click node_image_queries "https://github.com/petersolution/apipython/tree/master/queries/handlers/Images"
click node_user_model "https://github.com/petersolution/apipython/blob/master/models/user.py"
click node_entry_model "https://github.com/petersolution/apipython/blob/master/models/entryModel.py"
click node_row_model "https://github.com/petersolution/apipython/blob/master/models/entersInRowModel.py"
click node_image_model "https://github.com/petersolution/apipython/blob/master/models/imageModel.py"
click node_react_client "https://github.com/petersolution/apipython/blob/master/test_app/src/App.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app,node_user_routes,node_entry_routes,node_row_routes,node_image_routes,node_user toneBlue
class node_command_dispatcher,node_query_dispatcher toneAmber
class node_user_commands,node_entry_commands,node_row_commands,node_image_commands,node_user_queries,node_entry_queries,node_row_queries,node_image_queries toneMint
class node_user_model,node_entry_model,node_row_model,node_image_model,node_database toneRose
class node_react_client toneIndigo
```

## Components

### API and application

- [Flask server](https://github.com/petersolution/apipython/blob/master/Server.py): `Server.py`
- [User routes](https://github.com/petersolution/apipython/blob/master/routes/userRoutes.py): `routes/userRoutes.py`
- [Entry routes](https://github.com/petersolution/apipython/blob/master/routes/entriesRoutes.py): `routes/entriesRoutes.py`
- [Entry-row routes](https://github.com/petersolution/apipython/blob/master/routes/entriesInRowRoute.py): `routes/entriesInRowRoute.py`
- [Image routes](https://github.com/petersolution/apipython/blob/master/routes/ImagePatchRoute.py): `routes/ImagePatchRoute.py`

### Command and query dispatch

- [Command dispatcher](https://github.com/petersolution/apipython/blob/master/commands/__init__.py): `commands/__init__.py`
- [Query dispatcher](https://github.com/petersolution/apipython/blob/master/queries/__init__.py): `queries/__init__.py`

### Attendance domain

- [User commands](https://github.com/petersolution/apipython/tree/master/commands/handlers): `commands/handlers`
- [Entry commands](https://github.com/petersolution/apipython/blob/master/commands/handlers/Create_entry.py): `commands/handlers/Create_entry.py`
- [Entry-row commands](https://github.com/petersolution/apipython/tree/master/commands/handlers/EntriesInRow): `commands/handlers/EntriesInRow`
- [Image commands](https://github.com/petersolution/apipython/tree/master/commands/handlers/Images): `commands/handlers/Images`
- [User queries](https://github.com/petersolution/apipython/tree/master/queries/handlers): `queries/handlers`
- [Entry queries](https://github.com/petersolution/apipython/tree/master/queries/handlers): `queries/handlers`
- [Entry-row queries](https://github.com/petersolution/apipython/tree/master/queries/handlers/EntriesInRow): `queries/handlers/EntriesInRow`
- [Image queries](https://github.com/petersolution/apipython/tree/master/queries/handlers/Images): `queries/handlers/Images`

### Persistence models

- [User model](https://github.com/petersolution/apipython/blob/master/models/user.py): `models/user.py`
- [Entry model](https://github.com/petersolution/apipython/blob/master/models/entryModel.py): `models/entryModel.py`
- [Entry-row model](https://github.com/petersolution/apipython/blob/master/models/entersInRowModel.py): `models/entersInRowModel.py`
- [Image model](https://github.com/petersolution/apipython/blob/master/models/imageModel.py): `models/imageModel.py`
- **SQL database**

### Client

- [User management UI](https://github.com/petersolution/apipython/blob/master/test_app/src/App.js): `test_app/src/App.js`

### Other components

- **User**

## Connections

- Flask server → User routes: registers
- Flask server → Entry routes: registers
- Flask server → Entry-row routes: registers
- Flask server → Image routes: registers
- Flask server → SQL database: initializes
- User → User routes: requests
- User routes → Query dispatcher: dispatches queries
- User routes → Command dispatcher: dispatches commands
- Entry routes → Query dispatcher: dispatches queries
- Entry routes → Command dispatcher: dispatches commands
- Query dispatcher → User queries: invokes handler
- Query dispatcher → Entry queries: invokes handler
- Query dispatcher → Entry-row queries: invokes handler
- Query dispatcher → Image queries: invokes handler
- Command dispatcher → User commands: invokes handler
- Command dispatcher → Entry commands: invokes handler
- Command dispatcher → Entry-row commands: invokes handler
- Command dispatcher → Image commands: invokes handler
- User commands → User model: reads and writes
- User queries → User model: queries
- Entry queries → Entry model: queries
- Entry-row commands → Entry-row model: reads and writes
- Entry-row commands → Entry model: queries
- Entry-row commands → User model: queries
- Entry model → SQL database: persists in
- User model → SQL database: persists in
- Entry-row model → SQL database: persists in
- Image model → SQL database: persists in
- User management UI → User routes: calls user API
