# arrnavgargg/stocksim architecture

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

- Interactive diagram: https://gitdiagram.com/arrnavgargg/stocksim
- Repository: https://github.com/arrnavgargg/stocksim

## Overview

StockSim is presented as a virtual stock-trading and portfolio-management system, but the supplied runtime code currently implements only a FastAPI backend shell and authentication. The visible user workflow is registration, login for a bearer token, and token-authenticated retrieval of the current profile. Authentication uses an in-memory user registry, password hashing, and JWTs. Trading and portfolio stages are not represented in the supplied source, so they are omitted rather than inferred; configuration details are also limited because its source was not excerpted.

Main entry points: [`backend/app/routers/auth.py`](https://github.com/arrnavgargg/stocksim/blob/main/backend/app/routers/auth.py) (Auth routes), [`backend/app/routers/deps.py`](https://github.com/arrnavgargg/stocksim/blob/main/backend/app/routers/deps.py) (Token dependency), [`backend/app/main.py`](https://github.com/arrnavgargg/stocksim/blob/main/backend/app/main.py) (FastAPI app), [`backend/app/core/security.py`](https://github.com/arrnavgargg/stocksim/blob/main/backend/app/core/security.py) (Password and JWT)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API entry"]
  node_application["FastAPI app<br/>[main.py]"]
end

subgraph group_auth["Authentication"]
  node_auth_routes["Auth routes<br/>[auth.py]"]
  node_user_schemas["User schemas<br/>[user.py]"]
  node_user_registry[("In-memory users<br/>[auth.py]")]
  node_auth_dependencies["Token dependency<br/>[deps.py]"]
end

subgraph group_security["Security"]
  node_password_tokens["Password and JWT<br/>[security.py]"]
  node_settings["Security settings<br/>[config.py]"]
end

node_client(("API client"))

node_client -->|"sends requests"| node_application
node_application -->|"mounts routes"| node_auth_routes
node_auth_routes -->|"validates and returns"| node_user_schemas
node_auth_routes -->|"reads and writes"| node_user_registry
node_auth_routes -->|"hashes and signs"| node_password_tokens
node_auth_routes -->|"uses for profile"| node_auth_dependencies
node_auth_dependencies -->|"looks up user"| node_user_registry
node_auth_dependencies -->|"returns profile"| node_user_schemas
node_auth_dependencies -->|"reads JWT settings"| node_settings
node_password_tokens -->|"reads JWT settings"| node_settings

click node_application "https://github.com/arrnavgargg/stocksim/blob/main/backend/app/main.py"
click node_auth_routes "https://github.com/arrnavgargg/stocksim/blob/main/backend/app/routers/auth.py"
click node_user_schemas "https://github.com/arrnavgargg/stocksim/blob/main/backend/app/schemas/user.py"
click node_user_registry "https://github.com/arrnavgargg/stocksim/blob/main/backend/app/routers/auth.py"
click node_auth_dependencies "https://github.com/arrnavgargg/stocksim/blob/main/backend/app/routers/deps.py"
click node_password_tokens "https://github.com/arrnavgargg/stocksim/blob/main/backend/app/core/security.py"
click node_settings "https://github.com/arrnavgargg/stocksim/blob/main/backend/app/core/config.py"

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_application,node_client toneBlue
class node_auth_routes,node_user_schemas,node_user_registry,node_auth_dependencies toneAmber
class node_password_tokens,node_settings toneMint
```

## Components

### API entry

- [FastAPI app](https://github.com/arrnavgargg/stocksim/blob/main/backend/app/main.py): `backend/app/main.py`

### Authentication

- [Auth routes](https://github.com/arrnavgargg/stocksim/blob/main/backend/app/routers/auth.py): `backend/app/routers/auth.py`
- [User schemas](https://github.com/arrnavgargg/stocksim/blob/main/backend/app/schemas/user.py): `backend/app/schemas/user.py`
- [In-memory users](https://github.com/arrnavgargg/stocksim/blob/main/backend/app/routers/auth.py): `backend/app/routers/auth.py`
- [Token dependency](https://github.com/arrnavgargg/stocksim/blob/main/backend/app/routers/deps.py): `backend/app/routers/deps.py`

### Security

- [Password and JWT](https://github.com/arrnavgargg/stocksim/blob/main/backend/app/core/security.py): `backend/app/core/security.py`
- [Security settings](https://github.com/arrnavgargg/stocksim/blob/main/backend/app/core/config.py): `backend/app/core/config.py`

### Other components

- **API client**

## Connections

- API client → FastAPI app: sends requests (evidence: `backend/app/main.py`)
- FastAPI app → Auth routes: mounts routes (evidence: `backend/app/main.py`)
- Auth routes → User schemas: validates and returns (evidence: `backend/app/routers/auth.py`)
- Auth routes → In-memory users: reads and writes (evidence: `backend/app/routers/auth.py`)
- Auth routes → Password and JWT: hashes and signs (evidence: `backend/app/routers/auth.py`)
- Auth routes → Token dependency: uses for profile (evidence: `backend/app/routers/auth.py`)
- Token dependency → In-memory users: looks up user (evidence: `backend/app/routers/deps.py`)
- Token dependency → User schemas: returns profile (evidence: `backend/app/routers/deps.py`)
- Token dependency → Security settings: reads JWT settings (evidence: `backend/app/routers/deps.py`)
- Password and JWT → Security settings: reads JWT settings (evidence: `backend/app/core/security.py`)
