# yashu1113/applysmart-platform-api architecture

> Architecture diagram of the GitHub repository yashu1113/applysmart-platform-api, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/yashu1113/applysmart-platform-api
- Repository: https://github.com/yashu1113/applysmart-platform-api

## Overview

1. **Overall shape**
   ApplySmart Backend is a **FastAPI** application with a **feature-based layout** and **MongoDB** as the persistence layer. The code is split into shared platform concerns under `app/core` and business capabilities under `app/features`.

2. **Application entrypoint**
   `app/main.py` is the startup boundary. It is the place where the FastAPI app is created and feature routers are typically mounted, so the request path begins there and fans out into the feature modules.

3. **Core platform layer**
   `app/core` contains cross-cutting infrastructure used by multiple features:
   - `config.py` for environment/runtime configuration
   - `database.py` for MongoDB connection setup
   - `dependencies.py` for reusable FastAPI dependencies
   - `security.py` for authentication/authorization primitives
   - `mail.py` for shared mail delivery setup
   This layer is the main boundary between application logic and infrastructure concerns.

4. **Feature modules as bounded contexts**
   `app/features` holds the domain modules. The repository currently shows at least two feature areas:
   - `auth` for authentication flows
   - `users` for user management
   Each feature is self-contained with its own router and schema definitions, which keeps API surface, validation, and business logic grouped by capability.

5. **HTTP/API layer**
   Feature `router.py` files are the external API boundary. They receive FastAPI requests, validate inputs via `schemas.py`, and delegate to lower layers. This means the HTTP layer is intentionally thin and should not hold persistence or business rules.

6. **User management flow**
   The `users` feature includes:
   - `models.py` for the MongoDB-facing user shape
   - `schemas.py` for request/response validation
   - `service.py` for user-related business operations
   - `router.py` for API endpoints
   The flow is likely: request enters router → validated schema → service logic → database/model interaction → response schema returned.

7. **Authentication flow**
   The `auth` feature is the authentication boundary. It has its own `router.py` and `schemas.py`, and it likely relies heavily on `app/core/security.py` plus shared dependencies for token handling, password verification, or protected routes. This keeps auth-specific concerns separate from general user CRUD behavior.

8. **Shared email capability**
   There are two mail-related modules: `app/core/mail.py` and `app/features/common/email_service.py`. That suggests email is treated as a reusable capability, with core-level configuration and a feature/common service wrapper for sending messages such as verification or recovery emails.

9. **Data and dependency direction**
   The dependency direction is mostly one-way:
   **routers → schemas/services → core/database/security/mail**
   Routers should not reach across feature boundaries directly; instead they use shared core services or their own feature services. MongoDB is the main system of record, while FastAPI handles request routing and dependency injection.

10. **Configuration and runtime**
    The repo expects a local `.env` based on `.env.example`, which feeds app configuration at runtime. The documented runtime is Python 3.9+ with Uvicorn serving `app.main:app`. That means deployment is an ASGI Python service, with environment-driven settings and a MongoDB backend.

11. **What to draw in an architecture diagram**
    A good diagram would show:
    - Clients calling the FastAPI app
    - `main.py` mounting feature routers
    - `auth` and `users` as separate feature domains
    - shared `core` services for config, security, dependencies, database, and mail
    - MongoDB as the persistence store
    - an email-sending path from feature logic through shared mail services to an external mail provider

Main entry points: [`app/main.py`](https://github.com/yashu1113/applysmart-platform-api/blob/main/app/main.py) (App entry), [`app/features/auth/router.py`](https://github.com/yashu1113/applysmart-platform-api/blob/main/app/features/auth/router.py) (Auth API), [`app/features/users/service.py`](https://github.com/yashu1113/applysmart-platform-api/blob/main/app/features/users/service.py) (User service), [`app/features/users/router.py`](https://github.com/yashu1113/applysmart-platform-api/blob/main/app/features/users/router.py) (Users API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime"]
  node_client(("Client<br/>external actor"))
  node_main["App entry<br/>fastapi bootstrap<br/>[main.py]"]
  node_mongodb[("MongoDB<br/>datastore")]
  node_mailer["Mail provider<br/>external service"]
end

subgraph group_core["Core"]
  node_config["Config<br/>[config.py]"]
  node_db[("Database<br/>mongo connector<br/>[database.py]")]
  node_deps["Dependencies<br/>fastapi deps<br/>[dependencies.py]"]
  node_security["Security<br/>auth primitives<br/>[security.py]"]
  node_mail["Mail core<br/>mail setup<br/>[mail.py]"]
end

subgraph group_features["Features"]
  node_auth_router["Auth API<br/>feature router<br/>[router.py]"]
  node_auth_schemas["Auth schema<br/>validation schema<br/>[schemas.py]"]
  node_users_router["Users API<br/>feature router<br/>[router.py]"]
  node_users_schemas["User schema<br/>validation schema<br/>[schemas.py]"]
  node_users_service["User service<br/>business logic<br/>[service.py]"]
  node_users_model["User model<br/>mongo model<br/>[models.py]"]
  node_email_service["Email service<br/>feature service<br/>[email_service.py]"]
end

node_client -->|"HTTP requests"| node_main
node_main -->|"mounts"| node_auth_router
node_main -->|"mounts"| node_users_router
node_main -->|"loads"| node_config
node_main -->|"wires"| node_deps
node_main -->|"initializes"| node_db
node_main -->|"uses"| node_security
node_main -->|"wires"| node_mail
node_auth_router -->|"validates"| node_auth_schemas
node_auth_router -->|"depends on"| node_security
node_auth_router -->|"uses"| node_deps
node_users_router -->|"validates"| node_users_schemas
node_users_router -->|"delegates"| node_users_service
node_users_service -->|"persists"| node_users_model
node_users_service -->|"stores"| node_db
node_users_service -->|"notifies"| node_email_service
node_users_model -->|"persists to"| node_mongodb
node_db -->|"connects to"| node_mongodb
node_email_service -->|"uses"| node_mail
node_email_service -->|"sends mail"| node_mailer

click node_main "https://github.com/yashu1113/applysmart-platform-api/blob/main/app/main.py"
click node_config "https://github.com/yashu1113/applysmart-platform-api/blob/main/app/core/config.py"
click node_db "https://github.com/yashu1113/applysmart-platform-api/blob/main/app/core/database.py"
click node_deps "https://github.com/yashu1113/applysmart-platform-api/blob/main/app/core/dependencies.py"
click node_security "https://github.com/yashu1113/applysmart-platform-api/blob/main/app/core/security.py"
click node_mail "https://github.com/yashu1113/applysmart-platform-api/blob/main/app/core/mail.py"
click node_auth_router "https://github.com/yashu1113/applysmart-platform-api/blob/main/app/features/auth/router.py"
click node_auth_schemas "https://github.com/yashu1113/applysmart-platform-api/blob/main/app/features/auth/schemas.py"
click node_users_router "https://github.com/yashu1113/applysmart-platform-api/blob/main/app/features/users/router.py"
click node_users_schemas "https://github.com/yashu1113/applysmart-platform-api/blob/main/app/features/users/schemas.py"
click node_users_service "https://github.com/yashu1113/applysmart-platform-api/blob/main/app/features/users/service.py"
click node_users_model "https://github.com/yashu1113/applysmart-platform-api/blob/main/app/features/users/models.py"
click node_email_service "https://github.com/yashu1113/applysmart-platform-api/blob/main/app/features/common/email_service.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_client,node_main,node_mongodb,node_mailer toneBlue
class node_config,node_db,node_deps,node_security,node_mail toneAmber
class node_auth_router,node_auth_schemas,node_users_router,node_users_schemas,node_users_service,node_users_model,node_email_service toneMint
```

## Components

### Runtime

Application entrypoint and external actors

- **Client**: external actor · API consumers sending HTTP requests
- [App entry](https://github.com/yashu1113/applysmart-platform-api/blob/main/app/main.py): fastapi bootstrap · Creates the FastAPI app and mounts feature routers · `app/main.py`
- **MongoDB**: datastore · Primary system of record
- **Mail provider**: external service · Outbound email delivery target

### Core

Shared infrastructure and cross-cutting services

- [Config](https://github.com/yashu1113/applysmart-platform-api/blob/main/app/core/config.py): runtime config · Environment and settings loading · `app/core/config.py`
- [Database](https://github.com/yashu1113/applysmart-platform-api/blob/main/app/core/database.py): mongo connector · MongoDB connection and persistence setup · `app/core/database.py`
- [Dependencies](https://github.com/yashu1113/applysmart-platform-api/blob/main/app/core/dependencies.py): fastapi deps · Reusable dependency providers for routes and services · `app/core/dependencies.py`
- [Security](https://github.com/yashu1113/applysmart-platform-api/blob/main/app/core/security.py): auth primitives · Password, token, and authorization helpers · `app/core/security.py`
- [Mail core](https://github.com/yashu1113/applysmart-platform-api/blob/main/app/core/mail.py): mail setup · Shared email delivery configuration · `app/core/mail.py`

### Features

Bounded context modules

- [Auth API](https://github.com/yashu1113/applysmart-platform-api/blob/main/app/features/auth/router.py): feature router · Authentication HTTP boundary · `app/features/auth/router.py`
- [Auth schema](https://github.com/yashu1113/applysmart-platform-api/blob/main/app/features/auth/schemas.py): validation schema · Auth request and response models · `app/features/auth/schemas.py`
- [Users API](https://github.com/yashu1113/applysmart-platform-api/blob/main/app/features/users/router.py): feature router · User management HTTP boundary · `app/features/users/router.py`
- [User schema](https://github.com/yashu1113/applysmart-platform-api/blob/main/app/features/users/schemas.py): validation schema · User request and response models · `app/features/users/schemas.py`
- [User service](https://github.com/yashu1113/applysmart-platform-api/blob/main/app/features/users/service.py): business logic · User-related operations and orchestration · `app/features/users/service.py`
- [User model](https://github.com/yashu1113/applysmart-platform-api/blob/main/app/features/users/models.py): mongo model · MongoDB-facing user data shape · `app/features/users/models.py`
- [Email service](https://github.com/yashu1113/applysmart-platform-api/blob/main/app/features/common/email_service.py): feature service · Reusable email sending capability · `app/features/common/email_service.py`

## Connections

- Client → App entry: HTTP requests · Clients call the FastAPI application
- App entry → Auth API: mounts · Registers auth endpoints
- App entry → Users API: mounts · Registers user endpoints
- App entry → Config: loads · Builds app settings from environment
- App entry → Dependencies: wires · Installs shared dependencies
- App entry → Database: initializes · Creates persistence connectivity
- App entry → Security: uses · Shares security primitives across features
- App entry → Mail core: wires · Sets up shared mail capability
- Auth API → Auth schema: validates · Uses schemas for auth I/O
- Auth API → Security: depends on · Auth flow uses core security helpers
- Auth API → Dependencies: uses · Consumes shared FastAPI dependencies
- Users API → User schema: validates · Uses schemas for user I/O
- Users API → User service: delegates · Passes requests into business logic
- User service → User model: persists · Reads and writes user records
- User service → Database: stores · Uses MongoDB connection for persistence
- User service → Email service: notifies · Can trigger user-related emails
- User model → MongoDB: persists to · User data is stored in MongoDB
- Database → MongoDB: connects to · Core database layer manages the datastore connection
- Email service → Mail core: uses · Builds on shared mail configuration
- Email service → Mail provider: sends mail · Dispatches outbound email
